Class CollectionUtil

java.lang.Object
com.skava.helper.CollectionUtil

public final class CollectionUtil extends Object
The utility class CollectionUtil consists of helper and validator methods for collection entity.
Author:
Infosys Equinox
  • Method Details

    • isBusinessIdValid

      public static boolean isBusinessIdValid(Long businessId)

      isValidBusinessId

      This method is used to validate the collection identifier.
      Parameters:
      businessId - Indicates the business id of a collection which is used to validate the business id
      Returns:
      a boolean value. A collection identifier validation result.
    • isCollectionNameValid

      public static boolean isCollectionNameValid(String collectionName)
      isCollectionNameValid - Used to check if the collection name is valid.
      Parameters:
      collectionName - Indicates the collection name which is to be validated.
      Returns:
      a boolean value - true/false
    • getCollectionStatus

      public static CollectionStatus getCollectionStatus(Collection request)

      validateCollectionStatus

      Parameters:
      request - Instance of Collection which is used to get the collection status.
      Returns:
      collection status
    • isValidCollectionId

      public static boolean isValidCollectionId(Long collectionId)
      This method is used to validate the collection identifier.
      Parameters:
      collectionId - Indicates the collectionId which will be validated.
      Returns:
      a boolean value - true/false ie., if the collectionId is valid or not.
    • isValidCollection

      public static boolean isValidCollection(CommonServices commonServices, Long collectionId)
      Validating collection id
      Parameters:
      commonServices - Instance of CommonServices which is used to get the collection property.
      collectionId - Indicates the collectionId which is used to validate the collection id.
      Returns:
      Boolean value if valid collection true else false
    • validateCollectionAndBusinessId

      public static CollectionEntity validateCollectionAndBusinessId(CollectionRepository collectionRepository, org.springframework.context.MessageSource messageSource, Long collectionId, Long businessId, String locale)
      Validating collection and business id
      Parameters:
      collectionRepository - Instance of CollectionRepository which is used to validate the collection and business Id
      messageSource - Instance of MessageSource which is which is used to get the response for validating the collection and business id.
      collectionId - Indicates the collectionId which is used to validate the collection id.
      businessId - Indicates the business id of a collection which is used to validate the business id
      locale - API Response and error messages will be responded in the locale mentioned in this parameter.
      Returns:
      Instance of CollectionEntity object
    • getUpdatedCollectionProperties

      public static Set<CollectionPropertyEntity> getUpdatedCollectionProperties(CollectionEntity collection, List<CollectionProperty> requestProperties, List<CollectionAttributeEntity> attributes, org.springframework.context.MessageSource messageSource, String locale)
      Getting updated collection properties
      Parameters:
      collection - Instance of CollectionEntity which is used to get updated collection properties
      requestProperties - List of Instance of CollectionProperty object which is used to get updated collection properties.
      attributes - List of Instance of CollectionAttributeEntity object which is used to get updated collection properties.
      messageSource - Holds MessageSource which is used for response message and codes.
      locale - API Response and error messages will be responded in the locale mentioned in this parameter.
      Returns:
      Set of Instance of CollectionAttributeEntity
    • isCollectionPropertyAndAttributeEquals

      public static boolean isCollectionPropertyAndAttributeEquals(CollectionAttributeEntity attribute, CollectionProperty property)
      Validating collection property and attributes
      Parameters:
      attribute - Instance of CollectionAttributeEntity object which is used to validate the property.
      property - Instance of CollectionProperty which is used to validate the property name
      Returns:
      the boolean value
    • isCollectionPropertyHaveValidValue

      public static boolean isCollectionPropertyHaveValidValue(CollectionProperty property)
      Validating property value
      Parameters:
      property - Instance of CollectionProperty which is used to validate the property name
      Returns:
      the boolean value
    • getPropertyValue

      public static String getPropertyValue(CollectionAttributeEntity attribute, CollectionProperty requestProperty)
      Getting property value
      Parameters:
      attribute - Instance of CollectionAttributeEntity object which is used to get the collection property
      requestProperty - Instance of CollectionProperty which is used to get the property name
      Returns:
      the collection property value.
    • getCollectionProperties

      public static Set<CollectionPropertyEntity> getCollectionProperties(CollectionEntity collection, List<CollectionProperty> requestProperties, List<CollectionAttributeEntity> attributes, CommonServices commonServices, String locale)
      Used to get collection properties.
      Parameters:
      collection - Instance of CollectionEntity which is used to get collection property.
      requestProperties - List of Instance of CollectionProperty which is used to get collection property.
      attributes - List of Instance of CollectionAttributeEntity object which is used to get collection property.
      commonServices - Instance of CommonServices which is used tp get the collection property.
      locale - API Response and error messages will be responded in the locale mentioned in this parameter.
      Returns:
      Set of Instance of CollectionPropertyEntity
    • isPossibleValuesAvailable

      public static boolean isPossibleValuesAvailable(CollectionAttributeType attributeType)
      isPossibleValuesAvailable
      Parameters:
      attributeType - a CollectionAttributeType object.
      Returns:
      a Boolean object.
    • getPossibleValues

      public static List<String> getPossibleValues(CollectionAttributeEntity attribute)
      Parameters:
      attribute - a CollectionAttributeEntity object.
      Returns:
      a List of String objects.
    • buildSort

      public static org.springframework.data.domain.Sort buildSort(String sortStr)
      buildSort - to build the sort parameter.
      Parameters:
      sortStr - the sort string to build the sort object.
      Returns:
      the Sort object.
    • checkCollectionNameExists

      public static void checkCollectionNameExists(CollectionRepository collectionRepository, CollectionEntity collection, org.springframework.context.MessageSource messageSource, String locale)
    • sanitizeInput

      public static String sanitizeInput(String input)
      Parameters:
      input -
      Returns: