public class GroovyTools
extends java.lang.Object
Constructor and Description |
---|
GroovyTools() |
Modifier and Type | Method and Description |
---|---|
static boolean |
attributesValid(java.util.Map<java.lang.String,java.lang.Object> attributes,
java.util.Collection<java.lang.String> possibleAttributes,
java.util.Collection<java.lang.String> requiredAttributes,
java.util.Map<java.lang.String,java.lang.Class<?>> types)
Ensures that the attributes are valid.
|
static <T> void |
convertListItems(java.util.List list,
java.lang.Class<T> type,
java.util.function.Function<java.lang.Object,T> function)
Converts all of the list elements to the specified type by calling the function for any list elements that are not
the correct type.
|
static boolean |
hasAttributes(java.util.Map<java.lang.String,java.lang.Object> attributes,
java.lang.Iterable<java.lang.String> attributeNames)
Checks if the given attributes Map has all of the given attribute names.
|
static boolean |
hasAttributes(java.util.Map<java.lang.String,java.lang.Object> attributes,
java.lang.String... attributeNames)
Checks if the given attributes Map has all of the given attribute names.
|
static boolean |
hasAttributeTypes(java.util.Map<java.lang.String,java.lang.Object> attributes,
java.util.Map<java.lang.String,java.lang.Class<?>> types)
Checks if the given attributes Map has the correct types.
|
static void |
putDefaults(java.util.Map<java.lang.String,java.lang.Object> map,
java.util.Map<java.lang.String,java.lang.Object> defaults)
Puts all of the values from the defaults map into the main map if they are absent.
|
static java.util.List<java.lang.String> |
toListOfStrings(java.lang.Object value)
Converts the object to a List of Strings.
|
static java.lang.String |
toString(java.util.Map<java.lang.String,java.lang.Object> attributes,
java.lang.String key)
Safely converts an attribute to a String.
|
public static boolean attributesValid(java.util.Map<java.lang.String,java.lang.Object> attributes, java.util.Collection<java.lang.String> possibleAttributes, java.util.Collection<java.lang.String> requiredAttributes, java.util.Map<java.lang.String,java.lang.Class<?>> types)
attributes
- The attributes object.possibleAttributes
- The list of possible attributes. If an attributes is specified that doesn't exist in this
Collection, false will be returned.requiredAttributes
- A list of required attributes.types
- The attribute types.public static <T> void convertListItems(java.util.List list, java.lang.Class<T> type, java.util.function.Function<java.lang.Object,T> function)
T
- The type.list
- The list.type
- The type.function
- The function that is used to convert to the correct type.public static boolean hasAttributeTypes(java.util.Map<java.lang.String,java.lang.Object> attributes, java.util.Map<java.lang.String,java.lang.Class<?>> types)
attributes
- The attributes map.types
- The types.public static boolean hasAttributes(java.util.Map<java.lang.String,java.lang.Object> attributes, java.lang.Iterable<java.lang.String> attributeNames)
attributes
- The attributes map.attributeNames
- The attribute names.public static boolean hasAttributes(java.util.Map<java.lang.String,java.lang.Object> attributes, java.lang.String... attributeNames)
attributes
- The attributes map.attributeNames
- The attribute names.public static void putDefaults(java.util.Map<java.lang.String,java.lang.Object> map, java.util.Map<java.lang.String,java.lang.Object> defaults)
map
- The main map.defaults
- The defaults map.public static java.util.List<java.lang.String> toListOfStrings(java.lang.Object value)
value
- The value to convert.public static java.lang.String toString(java.util.Map<java.lang.String,java.lang.Object> attributes, java.lang.String key)
attributes
- The attributes.key
- The key of the attribute to convert.