Class ServicesUtil
java.lang.Object
de.hybris.platform.servicelayer.util.ServicesUtil
Utilities for handling e.g. exceptions in DAO classes in a common way, parameters etc.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidvalidateIfAnyResult(Collection resultToCheck, String unknownIdException) Checks if collection contains any objects.static voidvalidateIfSingleResult(Collection<? extends Object> resultToCheck, Class clazz, String qualifier, Object qualifierValue) Checks if collection contains only a single object and generates proper exception messages out of passed type and qualifier.static voidvalidateIfSingleResult(Collection<? extends Object> resultToCheck, String unknownIdException, String ambiguousIdException) Checks if collection contains only a single object.static voidvalidateParameterNotNull(Object parameter, String nullMessage) Validates if parameter passed to method is not nullstatic voidvalidateParameterNotNullStandardMessage(String parameter, Object parameterValue) Validates if parameter value passed to method is not null.
-
Constructor Details
-
ServicesUtil
public ServicesUtil()
-
-
Method Details
-
validateIfSingleResult
public static void validateIfSingleResult(Collection<? extends Object> resultToCheck, String unknownIdException, 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(Collection<? extends Object> resultToCheck, Class clazz, String qualifier, 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 objectIllegalStateException- if element in collection is NOT of the given type
-
validateIfAnyResult
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
Validates if parameter passed to method is not null- Parameters:
parameter- to checknullMessage- message for exception thrown if parameter is null- Throws:
IllegalArgumentException- if parameter is null
-
validateParameterNotNullStandardMessage
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:
IllegalArgumentException- if parameter is null
-