java.lang.Object
cl.netswitch.lib.util.Beans
Provides static utility methods that operate on Java beans.
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
Calls all setters in a destination object with values obtain from matching getters in a source object.static String
Converts an object to an XML string representation with no nulls.static String
Converts an object to an XML string representation with or without nulls.static String
Converts an object to a YAML string representation with no nulls.static String
Converts an object to a YAML string representation with or without nulls.
-
Method Details
-
copy
Calls all setters in a destination object with values obtain from matching getters in a source object.In other words, this method executes the following statement for all matching getters and setters.
destin.setProperty(source.getProperty());
A getter and setter match if the name and type of their respective properties are exactly the same.- Parameters:
source
- the object whose getter methods are invoked.destin
- the object whose setter methods are invoked.- Throws:
NullPointerException
- if an argument ifnull
.IllegalArgumentException
- if another error occurs.
-
toXML
Converts an object to an XML string representation with no nulls.See
toXML(Object, boolean)
for further details, because this is just a convenience method implemented by the following trivial statement:return toXML(object, false);
- Parameters:
object
- the object to be converted to XML (can be null).- Returns:
- an XML string representation of the supplied object.
- See Also:
-
toXML
Converts an object to an XML string representation with or without nulls.- Parameters:
object
- the object to be converted to XML (can be null).addNulls
- if true null values are added to the result.- Returns:
- an XML string representation of the supplied object.
-
toYAML
Converts an object to a YAML string representation with no nulls.See
toYAML(Object, boolean)
for further details, because this is just a convenience method implemented by the following trivial statement:return toYAML(object, false);
- Parameters:
object
- the object to be converted to YAML (can be null).- Returns:
- a YAML string representation of the supplied object.
- See Also:
-
toYAML
Converts an object to a YAML string representation with or without nulls.- Parameters:
object
- the object to be converted to YAML (can be null).addNulls
- if true null values are added to the result.- Returns:
- a YAML string representation of the supplied object.
-