Class ServicesUtil
- java.lang.Object
-
- de.hybris.platform.servicelayer.util.ServicesUtil
-
public class ServicesUtil extends java.lang.ObjectUtilities for handling e.g. exceptions in DAO classes in a common way, parameters etc.
-
-
Constructor Summary
Constructors Constructor Description ServicesUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidvalidateIfAnyResult(java.util.Collection resultToCheck, java.lang.String unknownIdException)Checks if collection contains any objects.static voidvalidateIfSingleResult(java.util.Collection<? extends java.lang.Object> resultToCheck, java.lang.Class clazz, java.lang.String qualifier, java.lang.Object qualifierValue)Checks if collection contains only a single object and generates proper exception messages out of passed type and qualifier.static voidvalidateIfSingleResult(java.util.Collection<? extends java.lang.Object> resultToCheck, java.lang.String unknownIdException, java.lang.String ambiguousIdException)Checks if collection contains only a single object.static voidvalidateParameterNotNull(java.lang.Object parameter, java.lang.String nullMessage)Validates if parameter passed to method is not nullstatic voidvalidateParameterNotNullStandardMessage(java.lang.String parameter, java.lang.Object parameterValue)Validates if parameter value passed to method is not null.
-
-
-
Method Detail
-
validateIfSingleResult
public static void validateIfSingleResult(java.util.Collection<? extends java.lang.Object> resultToCheck, java.lang.String unknownIdException, java.lang.String ambiguousIdException)Checks if collection contains only a single object.- Parameters:
resultToCheck- collection to checkunknownIdException- message for exception thrown if collection is empty or is nullambiguousIdException- message for exception thrown if collection has more than one object- Throws:
UnknownIdentifierException- if collection is empty or is nullAmbiguousIdentifierException- if collection has more than one object
-
validateIfSingleResult
public static void validateIfSingleResult(java.util.Collection<? extends java.lang.Object> resultToCheck, java.lang.Class clazz, java.lang.String qualifier, java.lang.Object qualifierValue)Checks if collection contains only a single object and generates proper exception messages out of passed type and qualifier.- Parameters:
resultToCheck- collection to checkclazz- result must contain elements which are assignable from this clazzqualifier- unique qualifier used for searchqualifierValue- for qualifier- Throws:
UnknownIdentifierException- if collection is empty or is nullAmbiguousIdentifierException- if collection has more than one objectjava.lang.IllegalStateException- if element in collection is NOT of the given type
-
validateIfAnyResult
public static void validateIfAnyResult(java.util.Collection resultToCheck, java.lang.String unknownIdException)Checks if collection contains any objects.- Parameters:
resultToCheck- collection to checkunknownIdException- message for exception thrown if collection is empty or is null- Throws:
UnknownIdentifierException- if collection is empty or is null
-
validateParameterNotNull
public static void validateParameterNotNull(java.lang.Object parameter, java.lang.String nullMessage)Validates if parameter passed to method is not null- Parameters:
parameter- to checknullMessage- message for exception thrown if parameter is null- Throws:
java.lang.IllegalArgumentException- if parameter is null
-
validateParameterNotNullStandardMessage
public static void validateParameterNotNullStandardMessage(java.lang.String parameter, java.lang.Object parameterValue)Validates if parameter value passed to method is not null.- Parameters:
parameter- name of parameter used for exception messageparameterValue- value to check for null- Throws:
java.lang.IllegalArgumentException- if parameter is null
-
-