Package liquibase
Class AbstractExtensibleObject
- java.lang.Object
-
- liquibase.AbstractExtensibleObject
-
- All Implemented Interfaces:
Cloneable
,ExtensibleObject
- Direct Known Subclasses:
AbstractLogger
,AbstractPlugin
,AbstractResourceAccessor
,CompositeUIService
,ConsoleUIService
,LoggerUIService
public class AbstractExtensibleObject extends Object implements ExtensibleObject
Convenience class implementing ExtensibleObject. It is usually easiest to extend this class rather than implement all of ExtensibleObject yourself.
-
-
Constructor Summary
Constructors Constructor Description AbstractExtensibleObject()
AbstractExtensibleObject(Map<String,?> values)
Creates a new object with the given attributes.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
clone()
ExposeCloneable#clone()
as publicString
describe()
Output a full description of this object.boolean
equals(Object obj)
Default implementation counts objects equal if their describe() methods return equal strings.<T> T
get(String attribute, Class<T> type)
Return the current value of the given attribute name, converted to the passed type.<T> T
get(String attribute, T defaultValue)
Works likeExtensibleObject.get(String, Class)
but if the attribute is null or not defined, returns the passed defaultValue.protected <T> T
get(String attribute, T defaultValue, Class<T> type)
SortedSet<String>
getAttributes()
Return the names of all the set attributes.protected Object
getFieldValue(String attribute, Class type)
ObjectMetaData
getObjectMetaData()
Returns theObjectMetaData
describing this instance.List
getValuePath(String attributes, Class lastType)
Traverses dot-separated attributes in the attributePath and returns a list containing all the intermediate values.boolean
has(String key)
Return true if the given key is defined.int
hashCode()
ExtensibleObject
set(String attribute, Object value)
Sets the value of the given attribute.String
toString()
-
-
-
Method Detail
-
getAttributes
public SortedSet<String> getAttributes()
Description copied from interface:ExtensibleObject
Return the names of all the set attributes. If an attribute is null the name should not be returned. Should return both "standard" attributes and any custom attributes that have been set.- Specified by:
getAttributes
in interfaceExtensibleObject
-
getObjectMetaData
public ObjectMetaData getObjectMetaData()
Description copied from interface:ExtensibleObject
Returns theObjectMetaData
describing this instance.- Specified by:
getObjectMetaData
in interfaceExtensibleObject
-
has
public boolean has(String key)
Return true if the given key is defined.- Specified by:
has
in interfaceExtensibleObject
-
get
public <T> T get(String attribute, Class<T> type)
Description copied from interface:ExtensibleObject
Return the current value of the given attribute name, converted to the passed type. If the passed attribute is null or not defined, returns null. If you do not know the type to convert to, pass Object.class as the type. Conversion is done usingObjectUtil.convert(Object, Class)
. Should traverse dot-separated attributes.- Specified by:
get
in interfaceExtensibleObject
-
get
public <T> T get(String attribute, T defaultValue)
Description copied from interface:ExtensibleObject
Works likeExtensibleObject.get(String, Class)
but if the attribute is null or not defined, returns the passed defaultValue. Uses the type of defaultValue to determine the type to convert the current value to.If null is passed to the default value, no conversion of attribute is made if it is set. If traversing a dot-separated attribute path, return the default value if any along the path are null.
- Specified by:
get
in interfaceExtensibleObject
-
getValuePath
public List getValuePath(String attributes, Class lastType)
Description copied from interface:ExtensibleObject
Traverses dot-separated attributes in the attributePath and returns a list containing all the intermediate values.- Specified by:
getValuePath
in interfaceExtensibleObject
lastType
- the type to convert the last value in the list to.
-
set
public ExtensibleObject set(String attribute, Object value)
Description copied from interface:ExtensibleObject
Sets the value of the given attribute. Subclasses can override this method to provide conversion business logic, but must remember that fields can be set directly when no type conversion is needed.- Specified by:
set
in interfaceExtensibleObject
-
describe
public String describe()
Description copied from interface:ExtensibleObject
Output a full description of this object. Should include all attributes and values.- Specified by:
describe
in interfaceExtensibleObject
-
equals
public boolean equals(Object obj)
Default implementation counts objects equal if their describe() methods return equal strings.
-
clone
public Object clone()
Description copied from interface:ExtensibleObject
ExposeCloneable#clone()
as public- Specified by:
clone
in interfaceExtensibleObject
- Overrides:
clone
in classObject
-
-