Class NumberAdapter

java.lang.Object
jakarta.xml.bind.annotation.adapters.XmlAdapter<String,Number>
de.gurkenlabs.litiengine.environment.tilemap.xml.NumberAdapter

public class NumberAdapter extends jakarta.xml.bind.annotation.adapters.XmlAdapter<String,Number>

XML adapter that converts between a String representation and a generic Number.

Used to serialize Number-typed fields of generic classes (e.g. Attribute) where the concrete numeric type cannot be recovered at unmarshalling time. The adapter always returns a Double when the value contains a decimal point (or scientific notation) and a Long otherwise. Consumers are expected to convert the returned Number to the desired concrete type via Number.floatValue(), Number.longValue(), etc.

  • Constructor Details

    • NumberAdapter

      public NumberAdapter()
  • Method Details

    • marshal

      public String marshal(Number value)
      Specified by:
      marshal in class jakarta.xml.bind.annotation.adapters.XmlAdapter<String,Number>
    • unmarshal

      public Number unmarshal(String value)
      Specified by:
      unmarshal in class jakarta.xml.bind.annotation.adapters.XmlAdapter<String,Number>