Skip to content

Commit d5f2e8e

Browse files
committed
Fix all compiler warnings in ocpp-common
1 parent b5056c4 commit d5f2e8e

14 files changed

Lines changed: 44 additions & 28 deletions

ocpp-common/src/main/java/eu/chargetime/ocpp/CallErrorException.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ of this software and associated documentation files (the "Software"), to deal
2727

2828
/** Exception returned to an outgoing request if an error is reported from the other end. */
2929
public class CallErrorException extends Exception {
30+
private static final long serialVersionUID = 2491636769263746241L;
3031

3132
private String errorCode;
3233
private String errorDescription;

ocpp-common/src/main/java/eu/chargetime/ocpp/NotConnectedException.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,6 @@ of this software and associated documentation files (the "Software"), to deal
2424
SOFTWARE.
2525
*/
2626

27-
public class NotConnectedException extends Exception {}
27+
public class NotConnectedException extends Exception {
28+
private static final long serialVersionUID = -2192470845608175121L;
29+
}

ocpp-common/src/main/java/eu/chargetime/ocpp/OccurenceConstraintException.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,6 @@ of this software and associated documentation files (the "Software"), to deal
2525
*/
2626

2727
/** Exception thrown when trying to send a request that isn't valid. */
28-
public class OccurenceConstraintException extends Exception {}
28+
public class OccurenceConstraintException extends Exception {
29+
private static final long serialVersionUID = -8870111792165582976L;
30+
}

ocpp-common/src/main/java/eu/chargetime/ocpp/PropertyConstraintException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ of this software and associated documentation files (the "Software"), to deal
2828

2929
/** Exception used when validating fields. */
3030
public class PropertyConstraintException extends IllegalArgumentException {
31-
31+
private static final long serialVersionUID = 7561578774874709893L;
3232
private static final String EXCEPTION_MESSAGE_TEMPLATE =
3333
"Validation failed: [%s]. Current Value: [%s]";
3434

ocpp-common/src/main/java/eu/chargetime/ocpp/SecurityErrorException.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ of this software and associated documentation files (the "Software"), to deal
2929

3030
/** A security issue occurred */
3131
public class SecurityErrorException extends IllegalStateException {
32+
private static final long serialVersionUID = 630599636179474207L;
33+
3234
public SecurityErrorException(String s) {
3335
super(s);
3436
}

ocpp-common/src/main/java/eu/chargetime/ocpp/model/validation/OptionalDecorator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ of this software and associated documentation files (the "Software"), to deal
2727

2828
public class OptionalDecorator extends Validator<String> {
2929

30-
private final Validator validator;
30+
private final Validator<String> validator;
3131

32-
public OptionalDecorator(Validator validator) {
32+
public OptionalDecorator(Validator<String> validator) {
3333
this.validator = validator;
3434
}
3535

ocpp-common/src/main/java/eu/chargetime/ocpp/model/validation/RequiredDecorator.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,17 @@ of this software and associated documentation files (the "Software"), to deal
2727

2828
import eu.chargetime.ocpp.PropertyConstraintException;
2929

30-
public class RequiredDecorator extends Validator<Object> {
30+
public class RequiredDecorator<T> extends Validator<T> {
3131

32-
private final Validator requiredValidator = new RequiredValidator();
33-
private final Validator decoratee;
32+
private final Validator<T> requiredValidator = new RequiredValidator<>();
33+
private final Validator<T> decoratee;
3434

35-
public RequiredDecorator(Validator validator) {
35+
public RequiredDecorator(Validator<T> validator) {
3636
this.decoratee = validator;
3737
}
3838

3939
@Override
40-
public void validate(Object value) throws PropertyConstraintException {
40+
public void validate(T value) throws PropertyConstraintException {
4141
requiredValidator.validate(value);
4242
decoratee.validate(value);
4343
}

ocpp-common/src/main/java/eu/chargetime/ocpp/model/validation/RequiredValidator.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ of this software and associated documentation files (the "Software"), to deal
2727

2828
import eu.chargetime.ocpp.PropertyConstraintException;
2929

30-
public class RequiredValidator extends Validator<Object> {
31-
private final String ERROR_MESSAGE = "Field is required and must not be Null.";
30+
public class RequiredValidator<T> extends Validator<T> {
31+
private static final String ERROR_MESSAGE = "Field is required and must not be Null.";
3232

3333
@Override
34-
public void validate(Object value) throws PropertyConstraintException {
34+
public void validate(T value) throws PropertyConstraintException {
3535
if (value == null) {
3636
throw new PropertyConstraintException(ERROR_MESSAGE, null);
3737
}

ocpp-common/src/main/java/eu/chargetime/ocpp/model/validation/ValidatorBuilder.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ of this software and associated documentation files (the "Software"), to deal
2929

3030
public class ValidatorBuilder {
3131

32+
private final ArrayList<IValidationRule> rules;
3233
private boolean required = false;
33-
private ArrayList<IValidationRule> rules;
3434

3535
public ValidatorBuilder() {
3636
rules = new ArrayList<>();
@@ -46,10 +46,10 @@ public ValidatorBuilder setRequired(boolean isRequired) {
4646
return this;
4747
}
4848

49-
public Validator build() {
50-
Validator validator = new StringValidator(rules.toArray(new IValidationRule[0]));
49+
public Validator<String> build() {
50+
Validator<String> validator = new StringValidator(rules.toArray(new IValidationRule[0]));
5151

52-
if (required) validator = new RequiredDecorator(validator);
52+
if (required) validator = new RequiredDecorator<>(validator);
5353
else validator = new OptionalDecorator(validator);
5454

5555
return validator;

ocpp-common/src/main/java/eu/chargetime/ocpp/utilities/TestUtilities.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
* SOFTWARE.
2727
*/
2828

29-
/** Utilities for tests. Used to quickly create usefull objects. */
29+
/** Utilities for tests. Used to quickly create useful objects. */
3030
public final class TestUtilities {
3131

3232
/**
@@ -57,6 +57,7 @@ public static String aString(int length) {
5757
* @param <T> The type of the elements.
5858
* @return An array of the given elements.
5959
*/
60+
@SuppressWarnings({"varargs", "unchecked"})
6061
public static <T> T[] aList(T... objects) {
6162
return objects;
6263
}
@@ -73,6 +74,6 @@ public static String join(String delimiter, Object[] array) {
7374

7475
for (Object current : array) output.append(String.format("%s%s", delimiter, current));
7576

76-
return output.toString().substring(1);
77+
return output.substring(1);
7778
}
7879
}

0 commit comments

Comments
 (0)