Class NumberDescriptor

java.lang.Object
com.northconcepts.datapipeline.foundations.core.Bean
com.northconcepts.datapipeline.foundations.number.NumberDescriptor
All Implemented Interfaces:
DataExceptionContributor, JsonSerializable, RecordSerializable, XmlSerializable, Serializable

public class NumberDescriptor extends Bean
See Also:
  • Constructor Details

    • NumberDescriptor

      public NumberDescriptor()
  • Method Details

    • isNegative

      public boolean isNegative()
    • setNegative

      public NumberDescriptor setNegative(boolean negative)
    • getWholeDigits

      public int getWholeDigits()
    • setWholeDigits

      public NumberDescriptor setWholeDigits(int wholeDigits)
    • getFractionDigits

      public int getFractionDigits()
    • setFractionDigits

      public NumberDescriptor setFractionDigits(int fractionDigits)
    • isSigned

      public boolean isSigned()
      Indicates if the number needs a sign; same as isNegative().
    • getPrecision

      public int getPrecision()
      Returns the total number of digits (whole plus fraction digits).
    • getScale

      public int getScale()
      Returns the number of fraction digits.
    • getFieldType

      public FieldType getFieldType()
      Returns the field type for the described number: INT, LONG or BIG_INTEGER for whole numbers and DOUBLE or BIG_DECIMAL for fractions, depending on the digit count.
    • parseNumber

      public Number parseNumber(String value)
      Parses the string into the Java number class of getFieldType(), e.g. an Integer for INT.
    • expandToFit

      public NumberDescriptor expandToFit(NumberDescriptor other)
      Widens this descriptor to also fit the other number: keeps the larger digit counts and becomes negative if either is.
    • fromBigDecimal

      public NumberDescriptor fromBigDecimal(BigDecimal bigDecimal)
      Describes the given value: its sign, whole digits (precision minus scale) and fraction digits (scale).
    • fromBigInteger

      public NumberDescriptor fromBigInteger(BigInteger bigInteger)
      Describes the given whole number: its sign and digit count.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Description copied from class: Bean
      Returns a basic JSON representation of this instance.
      Overrides:
      toString in class Bean
    • toRecord

      public Record toRecord()
      Description copied from interface: RecordSerializable
      Converts this object's state to a record that RecordSerializable.fromRecord(Record) can load.
      Specified by:
      toRecord in interface RecordSerializable
      Overrides:
      toRecord in class Bean
    • fromRecord

      public NumberDescriptor fromRecord(Record source)
      Description copied from interface: RecordSerializable
      Loads this instance's state from a record and returns this (for fluid API call chaining). For fluid API call chaining, the overridden method should change the declared return type to its class.
      Specified by:
      fromRecord in interface RecordSerializable
      Overrides:
      fromRecord in class Bean
      Parameters:
      source -
      Returns:
      this instance.
    • toXmlElement

      public Element toXmlElement(Document document)
      Description copied from interface: XmlSerializable
      Returns an element, created with document, describing this object; the default implementation throws a DataException.
    • fromXmlElement

      public NumberDescriptor fromXmlElement(Element element)