T - Self-reference to type.public abstract class HierarchicalType<T extends HierarchicalType<T>> extends Type<T> implements Identifiable
Copyright (c) 2013-2016 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.
| Modifier | Constructor and Description |
|---|---|
protected |
HierarchicalType(String id)
Constructor for creating the top level types in subclasses.
|
|
HierarchicalType(String id,
T parent)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
T |
commonAncestor(T type)
Returns the common ancestor of both types.
|
boolean |
equals(Object obj) |
String |
getId()
Returns the Id.
|
T |
getParent() |
int |
hashCode() |
boolean |
isOfType(T type)
Whether this, or any of the parent types, equals the given type.
|
protected HierarchicalType(String id) throws NullPointerException
id - The id of the type to make it identifiable.NullPointerException - if the id is nullpublic HierarchicalType(String id, T parent) throws NullPointerException
id - The id of the type to make it identifiable.parent - T; parent typeNullPointerException - if the id is nullpublic final String getId()
IdentifiablegetId in interface Identifiablepublic final T getParent()
null if this is a top level type.public final boolean isOfType(T type)
type - T; typepublic final T commonAncestor(T type)
type - T; other type.null if noneCopyright © 2014–2018 Delft University of Technology. All rights reserved.