Package org.opentrafficsim.base
Class HierarchicalType<T extends HierarchicalType<T>>
java.lang.Object
org.opentrafficsim.base.Type<T>
org.opentrafficsim.base.HierarchicalType<T>
- Type Parameters:
T- Self-reference to type.
- All Implemented Interfaces:
Identifiable
public abstract class HierarchicalType<T extends HierarchicalType<T>> extends Type<T> implements Identifiable
Super class for types with hierarchical structure. Upper level types without parent can be created in sub classes using a
protected constructor without parent.
Copyright (c) 2013-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.
- Version:
- $Revision$, $LastChangedDate$, by $Author$, initial version 30 jun. 2017
- Author:
- Alexander Verbraeck, Peter Knoppers, Wouter Schakel
-
Constructor Summary
Constructors Modifier Constructor Description protectedHierarchicalType(String id)Constructor for creating the top level types in subclasses.HierarchicalType(String id, T parent)Constructor. -
Method Summary
-
Constructor Details
-
HierarchicalType
Constructor for creating the top level types in subclasses.- Parameters:
id- String; The id of the type to make it identifiable.- Throws:
NullPointerException- if the id is null
-
HierarchicalType
Constructor.- Parameters:
id- String; The id of the type to make it identifiable.parent- T; parent type- Throws:
NullPointerException- if the id is null
-
-
Method Details
-
getId
Returns the Id.- Specified by:
getIdin interfaceIdentifiable- Returns:
- Id.
-
getParent
- Returns:
- parent or
nullif this is a top level type.
-
isOfType
Whether this, or any of the parent types, equals the given type.- Parameters:
type- T; type- Returns:
- whether this, or any of the parent types, equals the given type
-
commonAncestor
Returns the common ancestor of both types.- Parameters:
type- T; other type.- Returns:
- common ancestor of both types,
nullif none
-
hashCode
public int hashCode() -
equals
-