Class TypedObject<IDTYPE>

java.lang.Object
com.helger.commons.type.TypedObject<IDTYPE>
Type Parameters:
IDTYPE - The type of the ID.
All Implemented Interfaces:
IHasID<IDTYPE>, IHasObjectType, ITypedObject<IDTYPE>

@Immutable public final class TypedObject<IDTYPE> extends Object implements ITypedObject<IDTYPE>
Base implementation of an object that has an ObjectType and an ID.
This class is immutable if the type of the ID is immutable.
Author:
Philip Helger
  • Constructor Details

    • TypedObject

      public TypedObject(@Nonnull ITypedObject<IDTYPE> aObj)
      Parameters:
      aObj - The typed object to copy the stuff from. May not be null.
    • TypedObject

      public TypedObject(@Nonnull ObjectType aObjectType, @Nonnull IDTYPE aID)
      Constructor.
      Parameters:
      aObjectType - Object type to use. May not be null.
      aID - ID to be used. May not be null.
  • Method Details

    • getObjectType

      @Nonnull public ObjectType getObjectType()
      Specified by:
      getObjectType in interface IHasObjectType
      Returns:
      The type of the object. Never null.
    • getID

      @Nonnull public IDTYPE getID()
      Description copied from interface: IHasID
      Get the unique ID of this object. If the type is String than the returned value must match an XML NMToken expression (so e.g. no ':' in the ID)!
      Specified by:
      getID in interface IHasID<IDTYPE>
      Returns:
      The ID of this object. May not be null.
    • equals

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

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

      public String toString()
      Overrides:
      toString in class Object
    • create

      @Nonnull public static <IDTYPE> TypedObject<IDTYPE> create(@Nonnull ITypedObject<IDTYPE> aObj)
      Factory method
      Type Parameters:
      IDTYPE - The type of the ID.
      Parameters:
      aObj - The typed object to copy the stuff from. May not be null.
      Returns:
      new TypedObject
    • create

      @Nonnull public static <IDTYPE> TypedObject<IDTYPE> create(@Nonnull ObjectType aObjectType, @Nonnull IDTYPE aID)
      Factory method
      Type Parameters:
      IDTYPE - The type of the ID.
      Parameters:
      aObjectType - Object type to use. May not be null.
      aID - ID to be used. May not be null.
      Returns:
      new TypedObject