Class DecimalFloatAdapter
public class DecimalFloatAdapter
extends jakarta.xml.bind.annotation.adapters.XmlAdapter<String,Float>
An adapter for converting between String and Float values during XML serialization and deserialization.
This implementation ensures that float values are serialized as integers if they have no digits after the decimal point. For example:
- A float value of
5.0will be serialized as"5". - A float value of
5.5will remain serialized as"5.5".
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
DecimalFloatAdapter
public DecimalFloatAdapter()
-
-
Method Details
-
unmarshal
Converts aStringvalue from the XML into aFloatobject. -
marshal
Converts a
Floatvalue into aStringfor XML serialization.If the float value is
null, this method returnsnull. If the float value has no digits after the decimal point, it is serialized as an integer string. Otherwise, it is serialized as a standard float string.
-