Class 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 Detail

      • 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 Detail

      • 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.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode 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