java.lang.Object
nl.jqno.equalsverifier.internal.instantiators.ConcreteValues
All Implemented Interfaces:
Values

public final class ConcreteValues extends Object implements Values
Simple container for primitive and object values used to define a provided instantiator. This implementation of the Values interface is mutable so a collection of values can be constructed easily.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final boolean
     
    private final Map<String,Object>
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    ConcreteValues(boolean throwing)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    <T> T
    get(String fieldName)
    Returns the value stored under the given field name, cast to the desired type.
    boolean
    getBoolean(String fieldName)
    Returns the boolean value stored under the given field name.
    byte
    getByte(String fieldName)
    Returns the byte value stored under the given field name.
    char
    getChar(String fieldName)
    Returns the char value stored under the given field name.
    double
    getDouble(String fieldName)
    Returns the double value stored under the given field name.
    float
    getFloat(String fieldName)
    Returns the float value stored under the given field name.
    int
    getInt(String fieldName)
    Returns the int value stored under the given field name.
    long
    getLong(String fieldName)
    Returns the long value stored under the given field name.
    short
    getShort(String fieldName)
    Returns the short value stored under the given field name.
    getString(String fieldName)
    Returns the String value stored under the given field name.
    of(Map<Field,Object> values, boolean throwing)
    Creates an instance of ConcreteValues from a Map.
    void
    put(String fieldName, Object value)
    Stores a value under the given field name.
    private <T> T
    safe(Class<T> type, String fieldName)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • values

      private final Map<String,Object> values
    • throwing

      private final boolean throwing
  • Constructor Details

    • ConcreteValues

      private ConcreteValues(boolean throwing)
  • Method Details

    • of

      public static ConcreteValues of(Map<Field,Object> values, boolean throwing)
      Creates an instance of ConcreteValues from a Map.
      Parameters:
      values - The values to add to the new instance.
      throwing - Whether or not to throw when an unknown value is requested.
      Returns:
      An instance of ConcreteValues with the given values.
    • put

      public void put(String fieldName, Object value)
      Stores a value under the given field name.
      Parameters:
      fieldName - the name of the field
      value - the value to store
    • getBoolean

      public boolean getBoolean(String fieldName)
      Returns the boolean value stored under the given field name.
      Specified by:
      getBoolean in interface Values
      Parameters:
      fieldName - the name of the field
      Returns:
      the stored boolean value
    • getByte

      public byte getByte(String fieldName)
      Returns the byte value stored under the given field name.
      Specified by:
      getByte in interface Values
      Parameters:
      fieldName - the name of the field
      Returns:
      the stored byte value
    • getChar

      public char getChar(String fieldName)
      Returns the char value stored under the given field name.
      Specified by:
      getChar in interface Values
      Parameters:
      fieldName - the name of the field
      Returns:
      the stored char value
    • getDouble

      public double getDouble(String fieldName)
      Returns the double value stored under the given field name.
      Specified by:
      getDouble in interface Values
      Parameters:
      fieldName - the name of the field
      Returns:
      the stored double value
    • getFloat

      public float getFloat(String fieldName)
      Returns the float value stored under the given field name.
      Specified by:
      getFloat in interface Values
      Parameters:
      fieldName - the name of the field
      Returns:
      the stored float value
    • getInt

      public int getInt(String fieldName)
      Returns the int value stored under the given field name.
      Specified by:
      getInt in interface Values
      Parameters:
      fieldName - the name of the field
      Returns:
      the stored int value
    • getLong

      public long getLong(String fieldName)
      Returns the long value stored under the given field name.
      Specified by:
      getLong in interface Values
      Parameters:
      fieldName - the name of the field
      Returns:
      the stored long value
    • getShort

      public short getShort(String fieldName)
      Returns the short value stored under the given field name.
      Specified by:
      getShort in interface Values
      Parameters:
      fieldName - the name of the field
      Returns:
      the stored short value
    • getString

      public String getString(String fieldName)
      Returns the String value stored under the given field name.
      Specified by:
      getString in interface Values
      Parameters:
      fieldName - the name of the field
      Returns:
      the stored String value
    • get

      public <T> T get(String fieldName)
      Returns the value stored under the given field name, cast to the desired type.
      Specified by:
      get in interface Values
      Type Parameters:
      T - the type to cast to
      Parameters:
      fieldName - the name of the field
      Returns:
      the stored value cast to the requested type
    • safe

      private <T> T safe(Class<T> type, String fieldName)