Class AbstractLazyAttributeTypeImpl
- Object
-
- AbstractLazyAttributeTypeImpl
-
- All Implemented Interfaces:
AttributeType
,PropertyType
- Direct Known Subclasses:
AbstractLazyComplexTypeImpl
public abstract class AbstractLazyAttributeTypeImpl extends Object implements AttributeType
A replacement forAttributeTypeImpl
with lazy evaluation of super type, so types can be defined in any order. Note that type equality is defined by name, so do not allow different types with the same name to be put in any Collection.Inspired by
AttributeTypeImpl
andPropertyTypeImpl
.- Author:
- Ben Caradoc-Davies (CSIRO Earth Science and Resource Engineering)
- See Also:
AttributeTypeImpl
,PropertyTypeImpl
-
-
Constructor Summary
Constructors Constructor Description AbstractLazyAttributeTypeImpl(Name name, Class<?> binding, boolean identified, boolean isAbstract, List<Filter> restrictions, InternationalString description)
Constructor arguments have the same meaning as inAttributeTypeImpl
.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract AttributeType
buildSuper()
Subclasses must override this method to return the super type of this type or null if none.boolean
equals(Object other)
Equality by name.Class<?>
getBinding()
The java class that values of properties of the property type are bound to.InternationalString
getDescription()
Human readable description of this property type.Name
getName()
The name of the property type.List<Filter>
getRestrictions()
List of restrictions used define valid values for properties of this property type.AttributeType
getSuper()
Override ofPropertyType.getSuper()
which type narrows toAttributeType
.Map<Object,Object>
getUserData()
A map of "user data" which enables applications to store "application-specific" information against a property type.int
hashCode()
Hashcode override based onPropertyType.getName()
.boolean
isAbstract()
Flag indicating if the type is abstract or not.boolean
isIdentified()
Indicates if the type is identified or not.String
toString()
-
-
-
Constructor Detail
-
AbstractLazyAttributeTypeImpl
public AbstractLazyAttributeTypeImpl(Name name, Class<?> binding, boolean identified, boolean isAbstract, List<Filter> restrictions, InternationalString description)
Constructor arguments have the same meaning as inAttributeTypeImpl
.
-
-
Method Detail
-
buildSuper
public abstract AttributeType buildSuper()
Subclasses must override this method to return the super type of this type or null if none. This method will only be called once at most.- Returns:
- super type or null
-
isIdentified
public boolean isIdentified()
Description copied from interface:AttributeType
Indicates if the type is identified or not.If this method returns
true
, then the corresponding attribute must have a unique identifier, ie,Attribute.getIdentifier()
must return a value, and cannot benull
.- Specified by:
isIdentified
in interfaceAttributeType
- Returns:
true
if the attribute is identified, otherwisefalse
.- See Also:
AttributeType.isIdentified()
-
getSuper
public AttributeType getSuper()
Description copied from interface:AttributeType
Override ofPropertyType.getSuper()
which type narrows toAttributeType
.- Specified by:
getSuper
in interfaceAttributeType
- Specified by:
getSuper
in interfacePropertyType
- Returns:
- The parent or super type, or
null
. - See Also:
AttributeType.getSuper()
-
getName
public Name getName()
Description copied from interface:PropertyType
The name of the property type.Note that this is not the same name as
Property.getName()
, which is the name of the instance of the type, not the type itself.The returned name is a qualified name made up of two parts. The first a namespace uri (
Name.getNamespaceURI()
, and the second a local part (Name.getLocalPart()
.This value is never
null
.- Specified by:
getName
in interfacePropertyType
- Returns:
- The name of the property type.
- See Also:
PropertyType.getName()
-
getBinding
public Class<?> getBinding()
Description copied from interface:PropertyType
The java class that values of properties of the property type are bound to.This value is never
null
.- Specified by:
getBinding
in interfacePropertyType
- Returns:
- The binding of the property type.
- See Also:
PropertyType.getBinding()
-
isAbstract
public boolean isAbstract()
Description copied from interface:PropertyType
Flag indicating if the type is abstract or not.- Specified by:
isAbstract
in interfacePropertyType
- Returns:
true
if the type is abstract, otherwisefalse
.- See Also:
PropertyType.isAbstract()
-
getRestrictions
public List<Filter> getRestrictions()
Description copied from interface:PropertyType
List of restrictions used define valid values for properties of this property type.Each restriction is a
Filter
object in which the property is passed through. IfFilter.evaluate(Object)
returnstrue
the restriction is met. Iffalse
is returned then the restriction has not been met and the property should be considered invalid. Remember to check getSuper().getRestrictions() as well.This method returns an empty set in the case of no restrictions and should not return
null
.- Specified by:
getRestrictions
in interfacePropertyType
- Returns:
- List
used to validate allowable values. - See Also:
PropertyType.getRestrictions()
-
getDescription
public InternationalString getDescription()
Description copied from interface:PropertyType
Human readable description of this property type.- Specified by:
getDescription
in interfacePropertyType
- Returns:
- Human readable description of this property type.
- See Also:
PropertyType.getDescription()
-
getUserData
public Map<Object,Object> getUserData()
Description copied from interface:PropertyType
A map of "user data" which enables applications to store "application-specific" information against a property type.As an example, consider an application that builds a PropertyType from an xml schema. A useful bit of information to attach to the PropertyType is the original schema itself, in whatever construct it might be stored in:
XSDComplexTypeDefinition complexTypeDef = ...; PropertyType type = buildPropertyType( complexTypeDef ); type.getUserData().put( XSDComplexTypeDefintion.class, complexTypeDef );
- Specified by:
getUserData
in interfacePropertyType
- Returns:
- A map of user data.
- See Also:
PropertyType.getUserData()
-
equals
public boolean equals(Object other)
Equality by name. Yes, this may be a surprise to some client code, but how else do you define equality in the face of cyclic type definitions, without breaking encapsulation to analyse the full graph of types?- Specified by:
equals
in interfacePropertyType
- Overrides:
equals
in classObject
- Returns:
true
if other is a PropertyType with the same name- See Also:
Object.equals(java.lang.Object)
-
hashCode
public int hashCode()
Description copied from interface:PropertyType
Hashcode override based onPropertyType.getName()
.- Specified by:
hashCode
in interfacePropertyType
- Overrides:
hashCode
in classObject
- Returns:
- getName().hashCode()
- See Also:
Object.hashCode()
-
toString
public String toString()
- Overrides:
toString
in classObject
- See Also:
Object.toString()
-
-