Class StructuredInteger

java.lang.Object
net.visma.autopay.http.structured.StructuredItem
net.visma.autopay.http.structured.StructuredInteger
All Implemented Interfaces:
StructuredField

public final class StructuredInteger extends StructuredItem
Class representing Structured Integers. Also used as "bare" Integer in Structured parameters.
See Also:
  • Method Details

    • of

      public static StructuredInteger of(long value)
      Creates Structured Integer of given value, without parameters.
      Parameters:
      value - Item value
      Returns:
      Created Structured Integer
      Throws:
      IllegalArgumentException - When provided value is outside the allowed range, which is ±999,999,999,999,999
    • of

      public static StructuredInteger of(int value)
      Creates Structured Integer of given value, without parameters.
      Parameters:
      value - Item value
      Returns:
      Created Structured Integer
    • withParams

      public static StructuredInteger withParams(long value, Map<String,?> parameters)
      Creates Structured Integer of given value and parameters
      Parameters:
      value - Item value
      parameters - Parameter map. For details, check StructuredParameters.of(Map).
      Returns:
      Created Structured Integer
      Throws:
      IllegalArgumentException - When provided value is outside the allowed range
    • withParams

      public static StructuredInteger withParams(long value, StructuredParameters parameters)
      Creates Structured Integer of given value and parameters
      Parameters:
      value - Item value
      parameters - Structured Parameters
      Returns:
      Created Structured DInteger
    • intValue

      public int intValue()
      Returns int value of this Structured Integer

      (int) cast is used internally, which means that returned value will be incorrect for item values smaller than Integer.MIN_VALUE or grater than Integer.MAX_VALUE.

      Returns:
      int value represented by this Structured Integer
    • longValue

      public long longValue()
      Returns long value of this Structured Integer
      Returns:
      long value represented by this Structured Integer
    • doubleValue

      public double doubleValue()
      Returns double value of this Structured Integer
      Returns:
      double value represented by this Structured Integer
    • bigDecimalValue

      public BigDecimal bigDecimalValue()
      Returns BigDecimal value of this Structured Integer
      Returns:
      BigDecimal value represented by this Structured Integer
    • parse

      public static StructuredInteger parse(String httpHeader) throws StructuredException
      Parses given string for Structured Integer, according to the specification
      Parameters:
      httpHeader - String to parse, e.g. HTTP header
      Returns:
      Parsed Structured Integer
      Throws:
      StructuredException - Thrown in case of malformatted string or wrong item type
      See Also:
    • equals

      public boolean equals(Object o)
      Description copied from class: StructuredItem
      Compares the specified object with this Structured Item for equality. Returns true if the given object is of the same class as this Item, it has the same value and properties.
      Overrides:
      equals in class StructuredItem
      Parameters:
      o - Object to be compared with this Structured Item
      Returns:
      True is specified object is equal to this Structured Item
    • hashCode

      public int hashCode()
      Description copied from class: StructuredItem
      Returns hash code for this Structured Item. The hash code is a combination of hash codes of Item parameters and Item value.
      Overrides:
      hashCode in class StructuredItem
      Returns:
      The hash code for this Structured Item