Class TypedObject<IDTYPE>

java.lang.Object
com.helger.base.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

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

      public @NonNull IDTYPE getID()
      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

      public static <IDTYPE> @NonNull 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

      public static <IDTYPE> @NonNull 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