Package org.opentrafficsim.xml.bindings
Class StaticFieldAdapter<T,E extends ExpressionType<T>>
java.lang.Object
javax.xml.bind.annotation.adapters.XmlAdapter<String,E>
org.opentrafficsim.xml.bindings.ExpressionAdapter<T,E>
org.opentrafficsim.xml.bindings.StaticFieldAdapter<T,E>
- Type Parameters:
T
- value type wrapped in ExpressionTypeE
- ExpressionType
- Direct Known Subclasses:
AnticipationAdapter
,CooperationAdapter
,EncodingAdapter
,EstimationAdapter
,GapAcceptanceAdapter
,GraphicsTypeAdapter
,GtuPositionAdapter
,HeadwayDistributionAdapter
,InterpolationAdapter
,LaneKeepingPolicyAdapter
,SynchronizationAdapter
,TailgatingAdapter
public abstract class StaticFieldAdapter<T,E extends ExpressionType<T>>
extends ExpressionAdapter<T,E>
Superclass for adapters that parse types using static fields, including enums. This class assumes the following to be true
for the static fields:
- The XML type has values that match the static field names exactly.
- The static field names are present under the type class itself, e.g.
Synchronization.PASSIVE
is aSynchronization
. - The type class is either an
enum
, or itstoString()
method returns the field name, e.g.Synchronization.PASSIVE.toString()
gives"PASSIVE"
.
Copyright (c) 2023-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.
- Author:
- Wouter Schakel
-
Constructor Summary
ModifierConstructorDescriptionprotected
StaticFieldAdapter
(Class<T> valueType, Class<E> expressionType) Constructor. -
Method Summary
Methods inherited from class org.opentrafficsim.xml.bindings.ExpressionAdapter
isExpression, marshal, trimBrackets
-
Constructor Details
-
StaticFieldAdapter
Constructor.- Parameters:
valueType
- Class<T>; value type.expressionType
- Class<E>; expression type.
-
-
Method Details
-
marshal
- Overrides:
marshal
in classExpressionAdapter<T,
E extends ExpressionType<T>>
-
unmarshal
- Specified by:
unmarshal
in classExpressionAdapter<T,
E extends ExpressionType<T>> - Throws:
IllegalArgumentException
-