Package de.cuioss.test.valueobjects.util
Class PropertyHelper
java.lang.Object
de.cuioss.test.valueobjects.util.PropertyHelper
Provides utility methods for dealing with
PropertyMetadata
- Author:
- Oliver Wolff
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
assertPropertyExists
(String name, Map<String, PropertyMetadata> map) Simple assertions indicating that the property identified by the name exists in the given mapstatic void
assertPropertyExists
(String name, SortedSet<PropertyMetadata> givenMetadata) Simple assertions indicating that the property identified by the name exists in the given Setstatic final Set<PropertyConfig>
extractConfiguredPropertyConfigs
(Class<?> annotated) Checks the given type for the annotationPropertyConfig
andPropertyConfigs
and puts all found in the returned liststatic final Collection<PropertyMetadata>
handlePrimitiveAsDefaults
(Collection<PropertyMetadata> metadata) Sets all primitives of the given list toPropertyMetadata.isDefaultValue()
beingtrue
in casePropertyMetadata.getCollectionType()
beingCollectionType.NO_ITERABLE
.static final Set<PropertyMetadata>
handlePropertyConfigAnnotations
(Class<?> annotated) Checks the given type for the annotationPropertyConfig
andPropertyConfigs
and puts all found in the immutable set to be returnedstatic final Set<PropertyMetadata>
Checks the given type for the annotationPropertyConfig
andPropertyConfigs
and puts all found in the immutable set to be returnedstatic Map<String,
PropertyMetadata> handleWhiteAndBlacklist
(String[] of, String[] exclude, Collection<PropertyMetadata> givenMetadata) Handles the white- / black-list for the given parameterCollection
static List<PropertyMetadata>
handleWhiteAndBlacklistAsList
(String[] of, String[] exclude, List<PropertyMetadata> givenMetadata) Handles the white- / black-list for the given parameter map.static void
logMessageForPropertyMetadata
(Collection<? extends PropertyMetadata> handled) Simple helper method that creates a sensible information message for logging purpose.static void
logMessageForTargetPropertyMetadata
(Collection<? extends PropertyMetadata> handled) Simple helper method that creates a sensible information message for logging purpose.static final Map<String,
PropertyMetadata> toMapView
(Collection<PropertyMetadata> metadata) Simple helper, that create a map with with name as key for the givenPropertyMetadata
-
Constructor Details
-
PropertyHelper
public PropertyHelper()
-
-
Method Details
-
logMessageForPropertyMetadata
Simple helper method that creates a sensible information message for logging purpose. It uses a static field in order to ensure that the logging will only be done once per Test-unit *- Parameters:
handled
- to be logged
-
logMessageForTargetPropertyMetadata
public static void logMessageForTargetPropertyMetadata(Collection<? extends PropertyMetadata> handled) Simple helper method that creates a sensible information message for logging purpose. It uses a static field in order to ensure that the logging will only be done once per Test-unit *- Parameters:
handled
- to be logged
-
handlePrimitiveAsDefaults
public static final Collection<PropertyMetadata> handlePrimitiveAsDefaults(Collection<PropertyMetadata> metadata) Sets all primitives of the given list toPropertyMetadata.isDefaultValue()
beingtrue
in casePropertyMetadata.getCollectionType()
beingCollectionType.NO_ITERABLE
.- Parameters:
metadata
- must not be null- Returns:
- an immutable list with
PropertyMetadata
-
handlePropertyConfigAnnotations
Checks the given type for the annotationPropertyConfig
andPropertyConfigs
and puts all found in the immutable set to be returned- Parameters:
annotated
- the class that may or may not provide the annotations, must not be null- Returns:
- immutable set of found
PropertyMetadata
elements derived by the annotations.
-
handlePropertyConfigAnnotations
public static final Set<PropertyMetadata> handlePropertyConfigAnnotations(Collection<PropertyConfig> config) Checks the given type for the annotationPropertyConfig
andPropertyConfigs
and puts all found in the immutable set to be returned- Parameters:
config
- the PropertyConfig-annotations, must not be null- Returns:
- immutable set of found
PropertyMetadata
elements derived by the annotations.
-
extractConfiguredPropertyConfigs
Checks the given type for the annotationPropertyConfig
andPropertyConfigs
and puts all found in the returned list- Parameters:
annotated
- the class that may or may not provide the annotations, must not be null- Returns:
- a
Set
ofPropertyConfig
extract from the annotations of the given type. May be empty but never null
-
toMapView
Simple helper, that create a map with with name as key for the givenPropertyMetadata
- Parameters:
metadata
- if it is null or empty an emptyMap
will be returned.- Returns:
- a map with with name as key for the given
PropertyMetadata
-
handleWhiteAndBlacklist
public static Map<String,PropertyMetadata> handleWhiteAndBlacklist(String[] of, String[] exclude, Collection<PropertyMetadata> givenMetadata) Handles the white- / black-list for the given parameterCollection
- Parameters:
of
- must not be nullexclude
- must not be nullgivenMetadata
- must not be null- Returns:
- the filtered property map
-
handleWhiteAndBlacklistAsList
public static List<PropertyMetadata> handleWhiteAndBlacklistAsList(String[] of, String[] exclude, List<PropertyMetadata> givenMetadata) Handles the white- / black-list for the given parameter map. This variant returns a list with the exact order of the given list- Parameters:
of
- must not be nullexclude
- must not be nullgivenMetadata
- is it is null or empty an empty list will be returned.- Returns:
- the filtered properties
-
assertPropertyExists
Simple assertions indicating that the property identified by the name exists in the given map- Parameters:
name
- must no be nullmap
- must no be null
-
assertPropertyExists
Simple assertions indicating that the property identified by the name exists in the given Set- Parameters:
name
- must no be nullgivenMetadata
- must no be null
-