public class ElementHelper extends Object
| Constructor and Description |
|---|
ElementHelper() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
areEqual(Element a,
Object b)
A standard method for determining if two elements are equal.
|
static void |
copyProperties(Element from,
Element to)
Copy the properties (key and value) from one element to another.
|
static Map<String,Object> |
getProperties(Element element)
Get a clone of the properties of the provided element.
|
static boolean |
haveEqualIds(Element a,
Element b)
Simply tests if the element ids are equal().
|
static boolean |
haveEqualProperties(Element a,
Element b)
Determines whether two elements have the same properties.
|
static void |
removeProperties(Iterable<Element> elements)
Clear all the properties from an iterable of elements.
|
static void |
removeProperty(String key,
Iterable<Element> elements)
Remove a property from all elements in the provided iterable.
|
static void |
renameProperty(String oldKey,
String newKey,
Iterable<Element> elements)
Renames a property by removing the old key and adding the stored value to the new key.
|
static void |
setProperties(Element element,
Map<String,Object> properties)
Set the properties of the provided element using the provided map.
|
static void |
setProperties(Element element,
Object... keysValues)
Set the properties of the provided element using the provided key value pairs.
|
static void |
typecastProperty(String key,
Class classCast,
Iterable<Element> elements)
Typecasts a property value.
|
static void |
validateProperty(Element element,
String key,
Object value)
Determines whether the property key/value for the specified element can be legally set.
|
public static final void validateProperty(Element element, String key, Object value) throws IllegalArgumentException
element - the element for the property to be setkey - the key of the propertyvalue - the value of the propertyIllegalArgumentException - whether the triple is legal and if not, a clear reason message is providedpublic static void copyProperties(Element from, Element to)
from - the element to copy properties fromto - the element to copy properties topublic static void removeProperties(Iterable<Element> elements)
elements - the elements to remove properties frompublic static void removeProperty(String key, Iterable<Element> elements)
key - the property to remove by keyelements - the elements to remove the property frompublic static void renameProperty(String oldKey, String newKey, Iterable<Element> elements)
oldKey - the key to renamenewKey - the key to rename toelements - the elements to renamepublic static void typecastProperty(String key, Class classCast, Iterable<Element> elements)
key - the key for the property value to typecastclassCast - the class to typecast toelements - the elements to have their property typecastedpublic static boolean haveEqualProperties(Element a, Element b)
a - an elementb - an elementpublic static Map<String,Object> getProperties(Element element)
element - the element to get the properties ofpublic static void setProperties(Element element, Map<String,Object> properties)
element - the element to set the properties ofproperties - the properties to set as a Mappublic static void setProperties(Element element, Object... keysValues)
element - the element to set the properties ofkeysValues - the key value pairs of the propertiespublic static boolean areEqual(Element a, Object b)
a - The first elementb - The second element (as an object)Copyright © 2010-2014. All Rights Reserved.