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 116d2beefa..adbd3fbe19 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,8 +38,8 @@ public class Validator {
* This method validate EntityId entity id. If entity id is invalid than throw
* IncorrectParameterException exception
*
- * @param entityId the entityId
- * @param errorMessage the error message for exception
+ * @param entityId the entityId
+ * @param errorMessage the error message for exception
*/
public static void validateEntityId(EntityId entityId, String errorMessage) {
if (entityId == null || entityId.getId() == null) {
@@ -52,7 +52,7 @@ public class Validator {
* IncorrectParameterException exception
*
* @param entityId the entityId
- * @param errorMessageFunction the error message for exception that applies entityId
+ * @param errorMessageFunction the error message function for exception that applies entityId
*/
public static void validateEntityId(EntityId entityId, Function errorMessageFunction) {
if (entityId == null || entityId.getId() == null) {
@@ -64,8 +64,8 @@ public class Validator {
* This method validate String string. If string is invalid than throw
* IncorrectParameterException exception
*
- * @param val the val
- * @param errorMessage the error message for exception
+ * @param val the val
+ * @param errorMessage the error message for exception
*/
public static void validateString(String val, String errorMessage) {
if (val == null || val.isEmpty()) {
@@ -77,8 +77,8 @@ 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 applies 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()) {
@@ -90,8 +90,8 @@ public class Validator {
* This method validate long value. If value isn't positive than throw
* IncorrectParameterException exception
*
- * @param val the val
- * @param errorMessage the error message for exception
+ * @param val the val
+ * @param errorMessage the error message for exception
*/
public static void validatePositiveNumber(long val, String errorMessage) {
if (val <= 0) {
@@ -103,8 +103,8 @@ public class Validator {
* This method validate UUID id. If id is null than throw
* IncorrectParameterException exception
*
- * @param id the id
- * @param errorMessage the error message for exception
+ * @param id the id
+ * @param errorMessage the error message for exception
*/
public static void validateId(UUID id, String errorMessage) {
if (id == null) {
@@ -116,8 +116,8 @@ 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
+ * @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) {
@@ -129,8 +129,8 @@ public class Validator {
* This method validate UUIDBased id. If id is null than throw
* IncorrectParameterException exception
*
- * @param id the id
- * @param errorMessage the error message for exception
+ * @param id the id
+ * @param errorMessage the error message for exception
*/
public static void validateId(UUIDBased id, String errorMessage) {
if (id == null || id.getId() == null) {
@@ -142,8 +142,8 @@ 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
+ * @param id the id
+ * @param errorMessageFunction the error message function for exception that applies id
*/
public static void validateId(UUIDBased id, Function errorMessageFunction) {
if (id == null || id.getId() == null) {
@@ -151,12 +151,26 @@ public class Validator {
}
}
+ /**
+ * This method validate UUIDBased id. If id is null than throw
+ * IncorrectParameterException exception
+ *
+ * @param id the id
+ * @param ids the list of ids
+ * @param errorMessageFunction the error message function for exception that applies ids
+ */
+ static void validateId(UUIDBased id, List extends UUIDBased> ids, Function, String> errorMessageFunction) {
+ if (id == null) {
+ throw new IncorrectParameterException(errorMessageFunction.apply(ids));
+ }
+ }
+
/**
* 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 errorMessage the error message for exception
+ * @param ids the list of ids
+ * @param errorMessage the error message for exception
*/
public static void validateIds(List extends UUIDBased> ids, String errorMessage) {
if (ids == null || ids.isEmpty()) {
@@ -172,15 +186,15 @@ 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
+ * @param ids the list of ids
+ * @param errorMessageFunction the error message function 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));
+ validateId(id, ids, errorMessageFunction);
}
}
}
@@ -189,7 +203,7 @@ public class Validator {
* This method validate PageLink page link. If pageLink is invalid than throw
* IncorrectParameterException exception
*
- * @param pageLink the page link
+ * @param pageLink the page link
*/
public static void validatePageLink(PageLink pageLink) {
if (pageLink == null) {
diff --git a/dao/src/test/java/org/thingsboard/server/dao/service/ValidatorTest.java b/dao/src/test/java/org/thingsboard/server/dao/service/ValidatorTest.java
index f0a4938d64..14833627ba 100644
--- a/dao/src/test/java/org/thingsboard/server/dao/service/ValidatorTest.java
+++ b/dao/src/test/java/org/thingsboard/server/dao/service/ValidatorTest.java
@@ -111,7 +111,7 @@ class ValidatorTest {
.isInstanceOf(IncorrectParameterException.class)
.hasMessageContaining("Incorrect Ids []");
- List badList = new ArrayList<>(2);
+ List badList = new ArrayList<>(2);
badList.add(goodDeviceId);
badList.add(null);