Skip to content

Commit 0407ec7

Browse files
authored
Add nullability annotations to parser plugins (#827)
1 parent f6e76d5 commit 0407ec7

File tree

4 files changed

+25
-6
lines changed

4 files changed

+25
-6
lines changed

build.gradle

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,23 +110,33 @@ if (!project.hasProperty("android")) {
110110
namespace 'com.example'
111111

112112
compileSdkVersion 34
113+
113114
defaultConfig {
114115
minSdkVersion 21
115116
targetSdkVersion 33
116117
versionCode 1
117118
versionName "1.0"
118119
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
119120
}
121+
120122
compileOptions {
121123
coreLibraryDesugaringEnabled true
122124
sourceCompatibility JavaVersion.VERSION_1_8
123125
targetCompatibility JavaVersion.VERSION_1_8
124126
}
127+
125128
buildTypes {
126129
release {
127130
minifyEnabled false
128131
}
129132
}
133+
134+
configurations.configureEach {
135+
resolutionStrategy {
136+
// Fix mismatch with kotlin-stdlib
137+
force 'org.jetbrains:annotations:26.0.2'
138+
}
139+
}
130140
}
131141
}
132142

@@ -138,6 +148,7 @@ dependencies {
138148
api 'org.jetbrains.kotlin:kotlin-stdlib:1.6.10'
139149
api 'org.bouncycastle:bcprov-jdk18on:1.77'
140150
api 'net.sf.kxml:kxml2:2.3.0'
151+
compileOnly 'org.jetbrains:annotations:26.0.2'
141152

142153
// Upgrade to version higher than 1.4 when Collect minSDK >= 26
143154
api 'org.apache.commons:commons-csv:1.4'
@@ -149,4 +160,5 @@ dependencies {
149160
testImplementation 'junit:junit:4.13.2'
150161
testImplementation 'net.sf.kxml:kxml2:2.3.0'
151162
testImplementation 'org.hamcrest:hamcrest-all:1.3'
163+
testCompileOnly 'org.jetbrains:annotations:26.0.2'
152164
}

pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,12 @@
101101
<artifactId>hamcrest-all</artifactId>
102102
<version>1.3</version>
103103
</dependency>
104+
<dependency>
105+
<groupId>org.jetbrains</groupId>
106+
<artifactId>annotations</artifactId>
107+
<version>26.0.2</version>
108+
<scope>provided</scope>
109+
</dependency>
104110
</dependencies>
105111
<build>
106112
<plugins>

src/main/java/org/javarosa/xform/parse/XFormParser.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2491,16 +2491,16 @@ public interface FormDefProcessor extends Processor {
24912491

24922492
public interface BindAttributeProcessor extends Processor {
24932493

2494-
Set<Pair<String, String>> getBindAttributes();
2494+
@NotNull Set<@NotNull Pair<@NotNull String, @NotNull String>> getBindAttributes();
24952495

2496-
void processBindAttribute(String name, String value, DataBinding binding);
2496+
void processBindAttribute(@NotNull String name, @NotNull String value, @NotNull DataBinding binding);
24972497
}
24982498

24992499
public interface ModelAttributeProcessor extends Processor {
25002500

2501-
Set<Pair<String, String>> getModelAttributes();
2501+
@NotNull Set<@NotNull Pair<@NotNull String, @NotNull String>> getModelAttributes();
25022502

2503-
void processModelAttribute(String name, String value) throws ParseException;
2503+
void processModelAttribute(@NotNull String name, @NotNull String value) throws ParseException;
25042504
}
25052505

25062506
public interface QuestionProcessor extends Processor {

src/test/java/org/javarosa/xform/parse/BindAttributeProcessorTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import org.javarosa.core.model.instance.TreeReference;
88
import org.javarosa.test.XFormsElement;
99
import org.javarosa.model.xform.XPathReference;
10+
import org.jetbrains.annotations.NotNull;
1011
import org.junit.Test;
1112

1213
import java.io.ByteArrayInputStream;
@@ -105,12 +106,12 @@ public RecordingBindAttributeProcessor(Set<Pair<String, String>> attributes) {
105106
}
106107

107108
@Override
108-
public Set<Pair<String, String>> getBindAttributes() {
109+
public @NotNull Set<@NotNull Pair<@NotNull String, @NotNull String>> getBindAttributes() {
109110
return attributes;
110111
}
111112

112113
@Override
113-
public void processBindAttribute(String name, String value, DataBinding binding) {
114+
public void processBindAttribute(@NotNull String name, @NotNull String value, @NotNull DataBinding binding) {
114115
processCalled = true;
115116
}
116117
}

0 commit comments

Comments
 (0)