diff --git a/dao/src/main/java/org/thingsboard/server/dao/service/Validator.java b/dao/src/main/java/org/thingsboard/server/dao/service/Validator.java
index b3a121baf6..1cf94f2081 100644
--- a/dao/src/main/java/org/thingsboard/server/dao/service/Validator.java
+++ b/dao/src/main/java/org/thingsboard/server/dao/service/Validator.java
@@ -38,7 +38,7 @@ public class Validator {
* This method validate EntityId entity id. If entity id is invalid than throw
* IncorrectParameterException exception
*
- * @param entityId the entityId
+ * @param entityId the entityId
* @param errorMessage the error message for exception
*/
public static void validateEntityId(EntityId entityId, String errorMessage) {
@@ -51,8 +51,8 @@ public class Validator {
* This method validate EntityId entity id. If entity id is invalid than throw
* IncorrectParameterException exception
*
- * @param entityId the entityId
- * @param errorMessageFunction the error message for exception that apply entityId
+ * @param entityId the entityId
+ * @param errorMessageFunction the error message for exception that applies entityId
*/
public static void validateEntityId(EntityId entityId, Function errorMessageFunction) {
if (entityId == null || entityId.getId() == null) {
@@ -73,12 +73,12 @@ public class Validator {
}
}
- /*
+ /**
* This method validate String string. If string is invalid than throw
* IncorrectParameterException exception
*
- * @param val the value
- * @param errorMessageFunction the error message function that apply value
+ * @param val the value
+ * @param errorMessageFunction the error message function that applies value
*/
public static void validateString(String val, Function errorMessageFunction) {
if (val == null || val.isEmpty()) {
@@ -112,6 +112,18 @@ public class Validator {
}
}
+ /**
+ * This method validate UUID id. If id is null than throw
+ * IncorrectParameterException exception
+ *
+ * @param id the id
+ * @param errorMessageFunction the error message function for exception that applies id
+ */
+ public static void validateId(UUID id, Function errorMessageFunction) {
+ if (id == null) {
+ throw new IncorrectParameterException(errorMessageFunction.apply(id));
+ }
+ }
/**
* This method validate UUIDBased id. If id is null than throw
@@ -126,6 +138,19 @@ public class Validator {
}
}
+ /**
+ * This method validate UUIDBased id. If id is null than throw
+ * IncorrectParameterException exception
+ *
+ * @param id the id
+ * @param errorMessageFunction the error message for exception that applies id
+ */
+ public static void validateId(UUIDBased id, Function errorMessageFunction) {
+ if (id == null || id.getId() == null) {
+ throw new IncorrectParameterException(errorMessageFunction.apply(id));
+ }
+ }
+
/**
* This method validate list of UUIDBased ids. If at least one of the ids is null than throw
* IncorrectParameterException exception
@@ -143,6 +168,23 @@ public class Validator {
}
}
+ /**
+ * This method validate list of UUIDBased ids. If at least one of the ids is null than throw
+ * IncorrectParameterException exception
+ *
+ * @param ids the list of ids
+ * @param errorMessageFunction the error message for exception that applies ids
+ */
+ public static void validateIds(List extends UUIDBased> ids, Function, String> errorMessageFunction) {
+ if (ids == null || ids.isEmpty()) {
+ throw new IncorrectParameterException(errorMessageFunction.apply(ids));
+ } else {
+ for (UUIDBased id : ids) {
+ validateId(id, errorMessageFunction.apply(ids));
+ }
+ }
+ }
+
/**
* This method validate PageLink page link. If pageLink is invalid than throw
* IncorrectParameterException exception
@@ -189,4 +231,17 @@ public class Validator {
}
}
+ /**
+ * This method validate list of UUIDBased ids. If at least one of the ids is null than throw
+ * IncorrectParameterException exception
+ *
+ * @param reference the list of ids
+ * @param errorMessageFunction the error message for exception that applies reference
+ */
+ public static void checkNotNull(Object reference, Function