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>
  • Constructor Details

  • Method Details

    • 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 id
      name - attribute name
      description - attribute description
      contentType - 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 id
      name - attribute name
      contentType - 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)
      Set key as 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:
      getName in interface IDescribable
      Returns:
      the name of this object
    • getDescription

      public String getDescription()
      Specified by:
      getDescription in interface IDescribable
      Returns:
      the description of this object
    • getAccessor

      public final <U> IMemberAccessor<T,U> getAccessor(IType<U> type)
      Description copied from interface: IAccessorFactory
      Gets the accessor for specified type.
      Specified by:
      getAccessor in interface IAccessorFactory<V>
      Specified by:
      getAccessor in interface ICanonicalAccessorFactory<V>
      Type Parameters:
      U - input type class
      Parameters:
      type - type that the accessor should work for
      Returns:
      a member accessor or null if the type cannot provide such values
    • customAccessor

      public <U> IMemberAccessor<T,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<T> getKey()
      Specified by:
      getKey in interface ICanonicalAccessorFactory<V>
    • getContentType

      public ContentType<T> getContentType()
      Description copied from interface: IAccessorKey
      The 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 implement IItem.
      Specified by:
      getContentType in interface IAccessorKey<T>
      Returns:
      the content type of this attribute
    • getIdentifier

      public String getIdentifier()
      Description copied from interface: IAccessorKey
      A 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 to Field.getName().)
      Specified by:
      getIdentifier in interface IAccessorKey<T>
      Returns:
      the attribute identifier
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object