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-2020 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 Details

  • Method Details

    • getId

      public final String getId()
      Returns the Id.
      Specified by:
      getId in interface Identifiable
      Returns:
      Id.
    • getParent

      public final T getParent()
      Returns:
      parent or null if this is a top level type.
    • isOfType

      public final boolean isOfType​(T type)
      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

      public final T commonAncestor​(T type)
      Returns the common ancestor of both types.
      Parameters:
      type - T; other type.
      Returns:
      common ancestor of both types, null if none
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals​(Object obj)
      Overrides:
      equals in class Object