Package org.openjdk.jmc.common.item
Class Attribute<T>
- java.lang.Object
-
- org.openjdk.jmc.common.item.Attribute<T>
-
- All Implemented Interfaces:
IDescribable,IAccessorFactory<T>,IAccessorKey<T>,IAttribute<T>,ICanonicalAccessorFactory<T>
public class Attribute<T> extends Object implements IAttribute<T>
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <T> IAttribute<T>attr(String identifier, String name, String description, ContentType<T> contentType)Obtain an attribute.static <T> IAttribute<T>attr(String identifier, String name, ContentType<T> contentType)Obtain an attribute.static <T> ICanonicalAccessorFactory<T>attr(String identifier, ContentType<T> contentType)static <T> IAttribute<T>canonicalize(Attribute<T> key)Setkeyas the canonical (and only allowed) attribute for its equivalence class.<U> IMemberAccessor<V,U>customAccessor(IType<U> type)Override to construct deriving accessors.booleanequals(Object obj)<U> IMemberAccessor<V,U>getAccessor(IType<U> type)Gets the accessor for specified type.ContentType<T>getContentType()The content type of this attribute.StringgetDescription()StringgetIdentifier()A identifier is a text string identifying the attribute.IAccessorKey<V>getKey()StringgetName()inthashCode()StringtoString()-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.openjdk.jmc.common.item.ICanonicalAccessorFactory
getAccessor, getContentType, getIdentifier, getKey
-
-
-
-
Constructor Detail
-
Attribute
protected Attribute(String identifier, String name, String description, ContentType<T> contentType)
Protected constructor. Use one of the parameterized factory methods instead.- Parameters:
identifier- attribute idname- attribute namedescription- attribute descriptioncontentType- content type of the attribute values- See Also:
attr(String, String, String, ContentType),attr(String, String, ContentType)
-
-
Method Detail
-
attr
public static final <T> IAttribute<T> attr(String identifier, String name, String description, ContentType<T> contentType)
Obtain an attribute.- Type Parameters:
T- attribute value type- Parameters:
identifier- attribute idname- attribute namedescription- attribute descriptioncontentType- content type of the attribute values- Returns:
- an attribute
-
attr
public static final <T> IAttribute<T> attr(String identifier, String name, ContentType<T> contentType)
Obtain an attribute.- Type Parameters:
T- attribute value type- Parameters:
identifier- attribute idname- attribute namecontentType- content type of the attribute values- Returns:
- an attribute
-
attr
public static final <T> ICanonicalAccessorFactory<T> attr(String identifier, ContentType<T> contentType)
-
canonicalize
public static <T> IAttribute<T> canonicalize(Attribute<T> key)
Setkeyas the canonical (and only allowed) attribute for its equivalence class.- Type Parameters:
T- attribute value type- Parameters:
key- attribute to canonicalize- Returns:
- canonicalized attribute
- Throws:
IllegalStateException- if an equivalent attribute has already been canonicalized
-
getName
public String getName()
- Specified by:
getNamein interfaceIDescribable- Returns:
- the name of this object
-
getDescription
public String getDescription()
- Specified by:
getDescriptionin interfaceIDescribable- Returns:
- the description of this object
-
getAccessor
public final <U> IMemberAccessor<V,U> getAccessor(IType<U> type)
Description copied from interface:IAccessorFactoryGets the accessor for specified type.- Specified by:
getAccessorin interfaceIAccessorFactory<V>- Specified by:
getAccessorin interfaceICanonicalAccessorFactory<V>- Type Parameters:
U- input type class- Parameters:
type- type that the accessor should work for- Returns:
- a member accessor or
nullif the type cannot provide such values
-
customAccessor
public <U> IMemberAccessor<V,U> customAccessor(IType<U> type)
Override to construct deriving accessors. This will only be called when the type does not directly provide the attribute itself.- Type Parameters:
U- input type class- Parameters:
type- type to create accessor for- Returns:
- an accessor that works for the specified type or null if it can't be created
-
getKey
public IAccessorKey<V> getKey()
- Specified by:
getKeyin interfaceICanonicalAccessorFactory<V>
-
getContentType
public ContentType<T> getContentType()
Description copied from interface:IAccessorKeyThe content type of this attribute. The type can be an opaque (or leaf) type in which case its instances can be of any class (but typically restricted according to the type). It can also be a structured type which has attributes (fields) of its own, in which case its instances currently must implementIItem.- Specified by:
getContentTypein interfaceIAccessorKey<T>- Returns:
- the content type of this attribute
-
getIdentifier
public String getIdentifier()
Description copied from interface:IAccessorKeyA identifier is a text string identifying the attribute. It must never be localized and it should only contain characters that are safe to use in various configuration files, e.g. as XML tags. (Analogous toField.getName().)- Specified by:
getIdentifierin interfaceIAccessorKey<T>- Returns:
- the attribute identifier
-
-