Class ObjectWithUnitSerializer<U extends org.djunits.unit.Unit<U>,T>
java.lang.Object
org.djutils.serialization.serializers.BasicSerializer<T>
org.djutils.serialization.serializers.ObjectSerializer<T>
org.djutils.serialization.serializers.ObjectWithUnitSerializer<U,T>
- Type Parameters:
U- the unit typeT- the object type
- All Implemented Interfaces:
Serializer<T>
- Direct Known Subclasses:
DoubleScalarSerializer,DoubleVectorArraySerializer,FloatScalarSerializer,FloatVectorArraySerializer
public abstract class ObjectWithUnitSerializer<U extends org.djunits.unit.Unit<U>,T>
extends ObjectSerializer<T>
Abstract class to (de)serializes a DJUNITS value.
Copyright (c) 2019-2025 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See DJUNITS License.
- Author:
- Alexander Verbraeck
-
Constructor Summary
ConstructorsConstructorDescriptionObjectWithUnitSerializer(byte type, String dataClassName) Construct a new ObjectWithUnitSerializer. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidencodeUnit(U unit, byte[] message, Pointer pointer, Endianness endianness) Code a unit.protected UgetUnit(byte[] buffer, Pointer pointer, Endianness endianness) Retrieve and decode a DJUNITS unit.booleanhasUnit()Return whether the serializer uses a single unit type or not.Methods inherited from class org.djutils.serialization.serializers.ObjectSerializer
getNumberOfDimensions, serializeWithPrefix, sizeWithPrefixMethods inherited from class org.djutils.serialization.serializers.BasicSerializer
dataClassName, fieldType, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.djutils.serialization.serializers.Serializer
deSerialize, serialize, size
-
Constructor Details
-
ObjectWithUnitSerializer
Construct a new ObjectWithUnitSerializer.- Parameters:
type- the field type (returned by thefieldTypemethod)dataClassName- returned by the dataClassName method
-
-
Method Details
-
encodeUnit
Code a unit.- Parameters:
unit- the unit to code in the byte arraymessage- the byte arraypointer- the start pointer in the byte arrayendianness- encoder to use for multi-byte values
-
getUnit
Retrieve and decode a DJUNITS unit.- Parameters:
buffer- the encoded datapointer- position in the encoded data where the unit is to be decoded fromendianness- decoder for multi-byte values- Returns:
- Unit
-
hasUnit
public boolean hasUnit()Description copied from interface:SerializerReturn whether the serializer uses a single unit type or not.- Returns:
- whether the serializer uses a single unit type or not
-