Package org.opentcs.data
Class TCSObject<E extends TCSObject<E>>
java.lang.Object
org.opentcs.data.TCSObject<E>
- Type Parameters:
E
- The actual object class.
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
LocationType
,OrderSequence
,PeripheralJob
,TCSResource
,TransportOrder
,Vehicle
,VisualLayout
Describes the base behaviour of TCS data objects.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected TCSObjectReference
<E> A transient reference to this business object. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Checks if this object is equal to another one.getName()
Returns this object's name.Returns an unmodifiable view on this object's properties.getProperty
(String key) Returns the property value for the given key.Returns a transient/soft reference to this object.int
hashCode()
Returns this object's hashcode.protected static final <V> List
<V> listWithoutNullValues
(List<V> original) Returns a new list with the values from the given list but allnull
values removed.protected static final <K,
V> Map <K, V> mapWithoutNullValues
(Map<K, V> original) Returns a new map with the entries from the given map but all entries withnull
values removed.propertiesWith
(String key, String value) Returns a new map of this object's properties, with the given property integrated.protected static final <V> Set
<V> setWithoutNullValues
(Set<V> original) Returns a new set with the values from the given set but allnull
values removed.toString()
withHistory
(ObjectHistory history) Creates a copy of this object, with the given history.Creates a copy of this object, with the given history entry integrated.withProperties
(Map<String, String> properties) Creates a copy of this object, with the given properties.withProperty
(String key, String value) Creates a copy of this object, with the given property integrated.
-
Field Details
-
reference
A transient reference to this business object.
-
-
Constructor Details
-
TCSObject
Creates a new TCSObject.- Parameters:
objectName
- The new object's name.
-
TCSObject
protected TCSObject(@Nonnull String objectName, @Nonnull Map<String, 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
Returns this object's name.- Returns:
- This object's name.
-
getReference
Returns a transient/soft reference to this object.- Returns:
- A transient/soft reference to this object.
-
getProperties
Returns an unmodifiable view on this object's properties.- Returns:
- This object's properties.
-
getProperty
Returns the property value for the given key. This is basically a shortcut forgetProperties().get(key)
.- Parameters:
key
- The property's key.- Returns:
- The property value for the given key, or
null
, if there is none.
-
withProperty
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, ornull
, if the property is to be removed.- Returns:
- A copy of this object, with the given property integrated.
-
withProperties
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
-
withHistoryEntry
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
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
-
equals
Checks if this object is equal to another one. TwoTCSObject
s are equal if both their names and their runtime classes are equal. -
hashCode
public int hashCode()Returns this object's hashcode. ATCSObject
's hashcode is calculated by XORing its ID's hashcode and the hashcode of its runtime class's name. -
propertiesWith
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, ornull
, if the property is to be removed.- Returns:
- A new map of this object's properties, with the given property integrated.
-
mapWithoutNullValues
Returns a new map with the entries from the given map but all entries withnull
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
Returns a new list with the values from the given list but allnull
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
Returns a new set with the values from the given set but allnull
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.
-