Browse Source

Validator.validateEntityId with function added to reduce an overhead

pull/10328/head
Sergey Matvienko 3 years ago
parent
commit
45e9a9f642
  1. 13
      dao/src/main/java/org/thingsboard/server/dao/service/Validator.java

13
dao/src/main/java/org/thingsboard/server/dao/service/Validator.java

@ -47,6 +47,19 @@ public class Validator {
}
}
/**
* This method validate <code>EntityId</code> entity id. If entity id is invalid than throw
* <code>IncorrectParameterException</code> exception
*
* @param entityId the entityId
* @param errorMessageFunction the error message for exception that apply entityId
*/
public static void validateEntityId(EntityId entityId, Function<EntityId, String> errorMessageFunction) {
if (entityId == null || entityId.getId() == null) {
throw new IncorrectParameterException(errorMessageFunction.apply(entityId));
}
}
/**
* This method validate <code>String</code> string. If string is invalid than throw
* <code>IncorrectParameterException</code> exception

Loading…
Cancel
Save