Class DecimalDatatype

All Implemented Interfaces:
Comparable<Datatype>, Datatype, NumericDatatype, ValueDatatype

public class DecimalDatatype extends ValueClassNameDatatype implements NumericDatatype
Datatype for Decimal.
Author:
Jan Ortmann
  • Constructor Details

    • DecimalDatatype

      public DecimalDatatype()
  • Method Details

    • getValue

      public Object getValue(String s)
      Description copied from class: ValueClassNameDatatype
      This method parses the given string and returns the value as an instance of the class this value datatype represents. Use with caution: During development time Faktor-IPS maintains all values with their string representation. This allows to change the value's datatype without the need to convert the value from one class to another (e.g. if the string representation is 42 you can change the datatype from integer to string without converting the integer object to a string object.
      Specified by:
      getValue in interface ValueDatatype
      Specified by:
      getValue in class ValueClassNameDatatype
      Parameters:
      s - string representation of the value
      Returns:
      The value as instance of the class this datatype represents.
      See Also:
    • hasNullObject

      public boolean hasNullObject()
      Description copied from interface: Datatype
      Returns true if the datatype has a special instance representing null, otherwise false. The design pattern is called the null-object pattern.
      Specified by:
      hasNullObject in interface Datatype
      Overrides:
      hasNullObject in class ValueClassNameDatatype
      See Also:
      • NullObject
    • supportsCompare

      public boolean supportsCompare()
      Specified by:
      supportsCompare in interface ValueDatatype
      Returns:
      true if this datatype is able to compare two values.
    • subtract

      public String subtract(String minuend, String subtrahend)
      Description copied from interface: NumericDatatype
      Subtraction. This method is used to validate numeric ranges, see RangeValueSet as an example.
      Specified by:
      subtract in interface NumericDatatype
      Parameters:
      minuend - The value to be reduced.
      subtrahend - The value to be used to reduce the minuend
      Returns:
      The result of "minuend - subtrahend".
    • divisibleWithoutRemainder

      public boolean divisibleWithoutRemainder(String dividend, String divisor)
      Description copied from interface: NumericDatatype
      Decides whether the given dividend can be divided by the divisor without remainder or not. This method is used to validate numeric ranges, see RangeValueSet as an example.
      Specified by:
      divisibleWithoutRemainder in interface NumericDatatype
      Parameters:
      dividend - The value to be divided
      divisor - The value to be used to divide the dividend
      Returns:
      true if dividend can be divided by the divisor without remainder, false otherwise.
    • hasDecimalPlaces

      public boolean hasDecimalPlaces()
      Specified by:
      hasDecimalPlaces in interface NumericDatatype