Skip to content

Commit

Permalink
Add @NotNull to IAnswerData constructors (#794)
Browse files Browse the repository at this point in the history
  • Loading branch information
seadowg committed Sep 4, 2024
1 parent 30ef2a9 commit 41029da
Show file tree
Hide file tree
Showing 18 changed files with 27 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public String getDisplayText() {


@Override
public void setValue(Object o) {
public void setValue(@NotNull Object o) {
data = (Boolean) o;
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/javarosa/core/model/data/DateData.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public IAnswerData clone () {
}

@Override
public void setValue (Object o) {
public void setValue (@NotNull Object o) {
//Should not ever be possible to set this to a null value
if(o == null) {
throw new NullPointerException("Attempt to set an IAnswerData class to null.");
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/javarosa/core/model/data/DateTimeData.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public DateTimeData() {

}

public DateTimeData (Date d) {
public DateTimeData (@NotNull Date d) {
setValue(d);
}

Expand All @@ -52,7 +52,7 @@ public IAnswerData clone () {
}

@Override
public void setValue (Object o) {
public void setValue (@NotNull Object o) {
//Should not ever be possible to set this to a null value
if(o == null) {
throw new NullPointerException("Attempt to set an IAnswerData class to null.");
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/javarosa/core/model/data/DecimalData.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public DecimalData() {
public DecimalData(double d) {
this.d = d;
}
public DecimalData(Double d) {
public DecimalData(@NotNull Double d) {
setValue(d);
}

Expand All @@ -65,7 +65,7 @@ public String getDisplayText() {
}

@Override
public void setValue(Object o) {
public void setValue(@NotNull Object o) {
if(o == null) {
throw new NullPointerException("Attempt to set an IAnswerData class to null.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public String getDisplayText() {


@Override
public void setValue(Object o) {
public void setValue(@NotNull Object o) {
if (o == null) {
throw new NullPointerException("Attempt to set an IAnswerData class to null.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public String getDisplayText() {
}

@Override
public void setValue(Object o) {
public void setValue(@NotNull Object o) {
if (o == null) {
throw new NullPointerException("Attempt to set an IAnswerData class to null.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public String getDisplayText() {


@Override
public void setValue(Object o) {
public void setValue(@NotNull Object o) {
if (o == null) {
throw new NullPointerException("Attempt to set an IAnswerData class to null.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ static IAnswerData wrapData(Object val, int intDataType) {
* Null Data will not overwrite existing values.
* @throws NullPointerException if o is null
*/
void setValue (Object o); //can't be null
void setValue (@NotNull Object o); //can't be null
/**
* @return The value of this answer, will never
* be null
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/javarosa/core/model/data/IntegerData.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public IntegerData() {
public IntegerData(int n) {
this.n = n;
}
public IntegerData(Integer n) {
public IntegerData(@NotNull Integer n) {
setValue(n);
}

Expand All @@ -65,7 +65,7 @@ public String getDisplayText() {
}

@Override
public void setValue(Object o) {
public void setValue(@NotNull Object o) {
if(o == null) {
throw new NullPointerException("Attempt to set an IAnswerData class to null.");
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/javarosa/core/model/data/LongData.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public LongData() {
public LongData(long n) {
this.n = n;
}
public LongData(Long n) {
public LongData(@NotNull Long n) {
setValue(n);
}

Expand All @@ -64,7 +64,7 @@ public String getDisplayText() {
}

@Override
public void setValue(Object o) {
public void setValue(@NotNull Object o) {
if(o == null) {
throw new NullPointerException("Attempt to set an IAnswerData class to null.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public String getDisplayText() {
}

@Override
public void setValue(Object o) {
public void setValue(@NotNull Object o) {
if(o == null) {
throw new NullPointerException("Attempt to set an IAnswerData class to null.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public MultipleItemsData() {

}

public MultipleItemsData(List<Selection> vs) {
public MultipleItemsData(@NotNull List<Selection> vs) {
setValue(vs);
}

Expand All @@ -63,7 +63,7 @@ public IAnswerData clone () {
}

@Override
public void setValue (Object o) {
public void setValue (@NotNull Object o) {
if(o == null) {
throw new NullPointerException("Attempt to set an IAnswerData class to null.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public String getDisplayText() {
}

@Override
public void setValue(Object o) {
public void setValue(@NotNull Object o) {
if(o == null) {
throw new NullPointerException("Attempt to set an IAnswerData class to null.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.javarosa.core.model.data;

import org.javarosa.core.model.data.helper.Selection;
import org.jetbrains.annotations.NotNull;

import java.util.List;

Expand All @@ -32,7 +33,7 @@ public SelectMultiData() {

}

public SelectMultiData(List<Selection> vs) {
public SelectMultiData(@NotNull List<Selection> vs) {
setValue(vs);
}
}
4 changes: 2 additions & 2 deletions src/main/java/org/javarosa/core/model/data/SelectOneData.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public SelectOneData() {

}

public SelectOneData (Selection s) {
public SelectOneData (@NotNull Selection s) {
setValue(s);
}

Expand All @@ -55,7 +55,7 @@ public IAnswerData clone () {
}

@Override
public void setValue (Object o) {
public void setValue (@NotNull Object o) {
if(o == null) {
throw new NullPointerException("Attempt to set an IAnswerData class to null.");
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/javarosa/core/model/data/StringData.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public StringData() {

}

public StringData (String s) {
public StringData (@NotNull String s) {
setValue(s);
}

Expand All @@ -51,7 +51,7 @@ public IAnswerData clone () {
}

@Override
public void setValue (Object o) {
public void setValue (@NotNull Object o) {
//string should not be null or empty; the entire StringData reference should be null in this case
if(o == null) {
throw new NullPointerException("Attempt to set an IAnswerData class to null.");
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/javarosa/core/model/data/TimeData.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class TimeData implements IAnswerData {
public TimeData() {
}

public TimeData (Date d) {
public TimeData (@NotNull Date d) {
setValue(d);
}

Expand All @@ -47,7 +47,7 @@ public IAnswerData clone () {
}

@Override
public void setValue (Object o) {
public void setValue (@NotNull Object o) {
if(o == null) {
throw new NullPointerException("Attempt to set an IAnswerData class to null.");
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/javarosa/core/model/data/UncastData.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public String getDisplayText() {
}

@Override
public void setValue(Object o) {
public void setValue(@NotNull Object o) {
value = (String)o;
}

Expand Down

0 comments on commit 41029da

Please sign in to comment.