Class TCSObject<E extends TCSObject<E>>

java.lang.Object
org.opentcs.data.TCSObject<E>
Type Parameters:
E - The actual object class.
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
Group, LocationType, OrderSequence, PeripheralJob, TCSResource, TransportOrder, Vehicle, VisualLayout

public abstract class TCSObject<E extends TCSObject<E>>
extends java.lang.Object
implements java.io.Serializable
Describes the base behaviour of TCS data objects.
See Also:
Serialized Form
  • Field Summary

    Fields 
    Modifier and Type Field Description
    protected TCSObjectReference<E> reference
    A transient reference to this business object.
  • Constructor Summary

    Constructors 
    Modifier Constructor Description
    protected TCSObject​(java.lang.String objectName)
    Creates a new TCSObject.
    protected TCSObject​(java.lang.String objectName, java.util.Map<java.lang.String,​java.lang.String> properties, ObjectHistory history)
    Creates a new TCSObject.
  • Method Summary

    Modifier and Type Method Description
    boolean equals​(java.lang.Object obj)
    Checks if this object is equal to another one.
    ObjectHistory getHistory()  
    java.lang.String getName()
    Returns this object's name.
    java.util.Map<java.lang.String,​java.lang.String> getProperties()
    Returns an unmodifiable view on this object's properties.
    java.lang.String getProperty​(java.lang.String key)
    Returns the property value for the given key.
    TCSObjectReference<E> getReference()
    Returns a transient/soft reference to this object.
    int hashCode()
    Returns this object's hashcode.
    protected static <V> java.util.List<V> listWithoutNullValues​(java.util.List<V> original)
    Returns a new list with the values from the given list but all null values removed.
    protected static <K,​ V> java.util.Map<K,​V> mapWithoutNullValues​(java.util.Map<K,​V> original)
    Returns a new map with the entries from the given map but all entries with null values removed.
    protected java.util.Map<java.lang.String,​java.lang.String> propertiesWith​(java.lang.String key, java.lang.String value)
    Returns a new map of this object's properties, with the given property integrated.
    protected static <V> java.util.Set<V> setWithoutNullValues​(java.util.Set<V> original)
    Returns a new set with the values from the given set but all null values removed.
    java.lang.String toString()  
    abstract TCSObject<E> withHistory​(ObjectHistory history)
    Creates a copy of this object, with the given history.
    abstract TCSObject<E> withHistoryEntry​(ObjectHistory.Entry entry)
    Creates a copy of this object, with the given history entry integrated.
    abstract TCSObject<E> withProperties​(java.util.Map<java.lang.String,​java.lang.String> properties)
    Creates a copy of this object, with the given properties.
    abstract TCSObject<E> withProperty​(java.lang.String key, java.lang.String value)
    Creates a copy of this object, with the given property integrated.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

  • Constructor Details

    • TCSObject

      protected TCSObject​(@Nonnull java.lang.String objectName)
      Creates a new TCSObject.
      Parameters:
      objectName - The new object's name.
    • TCSObject

      protected TCSObject​(@Nonnull java.lang.String objectName, @Nonnull java.util.Map<java.lang.String,​java.lang.String> properties, @Nonnull ObjectHistory history)
      Creates a new TCSObject.
      Parameters:
      objectName - The new object's name.
      properties - A set of properties (key-value pairs) associated with this object.
      history - A history of events related to this object.
  • Method Details

    • getName

      @Nonnull public java.lang.String getName()
      Returns this object's name.
      Returns:
      This object's name.
    • getReference

      public TCSObjectReference<E> getReference()
      Returns a transient/soft reference to this object.
      Returns:
      A transient/soft reference to this object.
    • getProperties

      @Nonnull public java.util.Map<java.lang.String,​java.lang.String> getProperties()
      Returns an unmodifiable view on this object's properties.
      Returns:
      This object's properties.
    • getProperty

      @Nullable public java.lang.String getProperty​(java.lang.String key)
      Returns the property value for the given key. This is basically a shortcut for getProperties().get(key).
      Parameters:
      key - The property's key.
      Returns:
      The property value for the given key, or null, if there is none.
    • withProperty

      public abstract TCSObject<E> withProperty​(java.lang.String key, java.lang.String value)
      Creates a copy of this object, with the given property integrated.
      Parameters:
      key - The key of the property to be changed.
      value - The new value of the property, or null, if the property is to be removed.
      Returns:
      A copy of this object, with the given property integrated.
    • withProperties

      public abstract TCSObject<E> withProperties​(java.util.Map<java.lang.String,​java.lang.String> properties)
      Creates a copy of this object, with the given properties.
      Parameters:
      properties - The properties.
      Returns:
      A copy of this object, with the given properties.
    • getHistory

      public ObjectHistory getHistory()
    • withHistoryEntry

      public abstract TCSObject<E> withHistoryEntry​(ObjectHistory.Entry entry)
      Creates a copy of this object, with the given history entry integrated.
      Parameters:
      entry - The history entry to be integrated.
      Returns:
      A copy of this object, with the given history entry integrated.
    • withHistory

      public abstract TCSObject<E> withHistory​(ObjectHistory history)
      Creates a copy of this object, with the given history.
      Parameters:
      history - The history.
      Returns:
      A copy of this object, with the given history.
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object
    • equals

      public boolean equals​(java.lang.Object obj)
      Checks if this object is equal to another one. Two TCSObjects are equal if both their names and their runtime classes are equal.
      Overrides:
      equals in class java.lang.Object
      Parameters:
      obj - The object to compare this one to.
      Returns:
      true if, and only if, obj is also a TCSObject and both its name and runtime class equal those of this object.
    • hashCode

      public int hashCode()
      Returns this object's hashcode. A TCSObject's hashcode is calculated by XORing its ID's hashcode and the hashcode of its runtime class's name.
      Overrides:
      hashCode in class java.lang.Object
      Returns:
      This object's hashcode.
    • propertiesWith

      protected final java.util.Map<java.lang.String,​java.lang.String> propertiesWith​(java.lang.String key, java.lang.String value)
      Returns a new map of this object's properties, with the given property integrated.
      Parameters:
      key - The key of the property to be changed.
      value - The new value of the property, or null, if the property is to be removed.
      Returns:
      A new map of this object's properties, with the given property integrated.
    • mapWithoutNullValues

      protected static final <K,​ V> java.util.Map<K,​V> mapWithoutNullValues​(java.util.Map<K,​V> original)
      Returns a new map with the entries from the given map but all entries with null values removed.
      Type Parameters:
      K - The type of the map's keys.
      V - The type of the map's values.
      Parameters:
      original - The original map.
      Returns:
      A new map with the entries from the given map but all entries with null values removed.
    • listWithoutNullValues

      protected static final <V> java.util.List<V> listWithoutNullValues​(java.util.List<V> original)
      Returns a new list with the values from the given list but all null values removed.
      Type Parameters:
      V - The type of the list's values.
      Parameters:
      original - The original list.
      Returns:
      A new list with the values from the given list but all null values removed.
    • setWithoutNullValues

      protected static final <V> java.util.Set<V> setWithoutNullValues​(java.util.Set<V> original)
      Returns a new set with the values from the given set but all null values removed.
      Type Parameters:
      V - The type of the set's values.
      Parameters:
      original - The original set.
      Returns:
      A new set with the values from the given set but all null values removed.