Package com.helger.commons.type
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 anObjectTypeand an ID.
This class is immutable if the type of the ID is immutable.- Author:
- Philip Helger
-
-
Constructor Summary
Constructors Constructor Description TypedObject(ITypedObject<IDTYPE> aObj)TypedObject(ObjectType aObjectType, IDTYPE aID)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <IDTYPE> TypedObject<IDTYPE>create(ITypedObject<IDTYPE> aObj)Factory methodstatic <IDTYPE> TypedObject<IDTYPE>create(ObjectType aObjectType, IDTYPE aID)Factory methodbooleanequals(Object o)IDTYPEgetID()Get the unique ID of this object.ObjectTypegetObjectType()inthashCode()StringtoString()-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.helger.commons.type.IHasObjectType
getObjectTypeName, hasObjectType
-
-
-
-
Constructor Detail
-
TypedObject
public TypedObject(@Nonnull ITypedObject<IDTYPE> aObj)
- Parameters:
aObj- The typed object to copy the stuff from. May not benull.
-
TypedObject
public TypedObject(@Nonnull ObjectType aObjectType, @Nonnull IDTYPE aID)
Constructor.- Parameters:
aObjectType- Object type to use. May not benull.aID- ID to be used. May not benull.
-
-
Method Detail
-
getObjectType
@Nonnull public ObjectType getObjectType()
- Specified by:
getObjectTypein interfaceIHasObjectType- Returns:
- The type of the object. Never
null.
-
getID
@Nonnull public IDTYPE getID()
Description copied from interface:IHasIDGet the unique ID of this object. If the type isStringthan the returned value must match an XML NMToken expression (so e.g. no ':' in the ID)!
-
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 benull.- 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 benull.aID- ID to be used. May not benull.- Returns:
- new
TypedObject
-
-