Class Values

java.lang.Object
org.assertj.db.util.Values

public class Values extends Object
Utility methods related to values.
Author:
Régis Pouiller, Otoniel Isidoro
  • Method Details

    • areEqual

      public static boolean areEqual(Value value, Object expected)
      Returns if the value is equal to another value in parameter.
      Parameters:
      value - The value.
      expected - The other value to compare.
      Returns:
      true if the value is equal to the value in parameter, false otherwise.
    • areEqual

      public static boolean areEqual(Value value, Boolean expected)
      Returns if the value is equal to the Boolean in parameter.
      Parameters:
      value - The value.
      expected - The Boolean to compare.
      Returns:
      true if the value is equal to the Boolean parameter, false otherwise.
    • areEqual

      public static boolean areEqual(Value value, Number expected)
      Returns if the value is equal to the Number in parameter.
      Parameters:
      value - The value.
      expected - The Number to compare.
      Returns:
      true if the value is equal to the Number parameter, false otherwise.
    • areEqual

      public static boolean areEqual(Value value, byte[] expected)
      Returns if the value is equal to the array of byte in parameter.
      Parameters:
      value - The value.
      expected - The array of byte to compare.
      Returns:
      true if the value is equal to the array of byte parameter, false otherwise.
    • areEqual

      public static boolean areEqual(Value value, String expected)
      Returns if the value is equal to the String in parameter.
      Parameters:
      value - The value.
      expected - The String to compare.
      Returns:
      true if the value is equal to the String parameter, false otherwise.
      Throws:
      NullPointerException - if expected is null.
      AssertJDBException - If value is a Number and it is not possible to compare to expected.
    • areEqual

      public static boolean areEqual(Value value, Character expected)
      Returns if the value is equal to the String in parameter.
      Parameters:
      value - The value.
      expected - The Character to compare.
      Returns:
      true if the value is equal to the Character parameter, false otherwise.
      Throws:
      NullPointerException - if expected is null.
      Since:
      1.2.0
    • areEqual

      public static boolean areEqual(Value value, UUID expected)
      Returns if the value is equal to the UUID in parameter.
      Parameters:
      value - The value.
      expected - The UUID to compare.
      Returns:
      true if the value is equal to the UUID parameter, false otherwise.
      Since:
      1.1.0
    • areEqual

      public static boolean areEqual(UUID value, String expected)
      Returns if the UUID value is equal to the String in parameter.
      Parameters:
      value - The UUID value.
      expected - The String to compare.
      Returns:
      true if the UUID value is equal to the String parameter, false otherwise.
      Throws:
      AssertJDBException - If it is not possible to compare UUID to expected.
      Since:
      1.1.0
    • areEqual

      public static boolean areEqual(Value value, DateValue expected)
      Returns if the value is equal to the DateValue in parameter.
      Parameters:
      value - The value.
      expected - The DateValue to compare.
      Returns:
      true if the value is equal to the DateValue parameter, false otherwise.
    • areEqual

      public static boolean areEqual(Value value, TimeValue expected)
      Returns if the value is equal to the TimeValue in parameter.
      Parameters:
      value - The value.
      expected - The TimeValue to compare.
      Returns:
      true if the value is equal to the TimeValue parameter, false otherwise.
    • areEqual

      public static boolean areEqual(Value value, DateTimeValue expected)
      Returns if the value is equal to the DateTimeValue in parameter.
      Parameters:
      value - The value.
      expected - The DateTimeValue to compare.
      Returns:
      true if the value is equal to the DateTimeValue parameter, false otherwise.
    • compare

      public static int compare(Value value, Number expected)
      Returns the result of the comparison between the value and the Number in parameter.
      Parameters:
      value - The value.
      expected - The Number to compare.
      Returns:
      0 if the value is equal to the Number parameter, -1 if value is less than the Number parameter and 1 if value is greater than the Number parameter.
    • getRepresentationsFromValuesInFrontOfExpected

      public static Object[] getRepresentationsFromValuesInFrontOfExpected(Value[] values, Object[] expected)
      Returns a representation of the values (this representation is used for error message).
      Parameters:
      values - Values in the database.
      expected - Expected values for comparison.
      Returns:
      A representation of the values.
      Throws:
      AssertJDBException - If the length of the two arrays are different.
    • getRepresentationFromValueInFrontOfExpected

      public static Object getRepresentationFromValueInFrontOfExpected(Value value, Object expected)
      Returns a representation of the value (this representation is used for error message).
      Parameters:
      value - Value in the database.
      expected - Expected value for comparison.
      Returns:
      A representation of the value.
    • getRepresentationFromValueInFrontOfClass

      public static Object getRepresentationFromValueInFrontOfClass(Value value, Class<?> clazz)
      Returns a representation of the value (this representation is used for error message).
      Parameters:
      value - Value in the database.
      clazz - Class for comparison.
      Returns:
      A representation of the value.
    • areClose

      public static boolean areClose(Value value, Number expected, Number tolerance)
      Returns if the value is close to the Number in parameter with the tolerance in parameter.
      Parameters:
      value - The value.
      expected - The Number to compare.
      tolerance - The tolerance of the closeness.
      Returns:
      true if the value is close to the Number parameter, false otherwise.
    • areClose

      public static boolean areClose(Value value, DateValue expected, DateValue tolerance)
      Returns if the value is close to the DateValue in parameter with the tolerance in parameter.
      Parameters:
      value - The value.
      expected - The DateValue to compare.
      tolerance - The tolerance of the closeness.
      Returns:
      true if the value is close to the DateValue parameter, false otherwise.
    • areClose

      public static boolean areClose(Value value, DateValue expected, TimeValue tolerance)
      Returns if the value is close to the DateValue in parameter with the tolerance in parameter.
      Parameters:
      value - The value.
      expected - The DateValue to compare.
      tolerance - The tolerance of the closeness.
      Returns:
      true if the value is close to the DateValue parameter, false otherwise.
    • areClose

      public static boolean areClose(Value value, DateValue expected, DateTimeValue tolerance)
      Returns if the value is close to the DateValue in parameter with the tolerance in parameter.
      Parameters:
      value - The value.
      expected - The DateValue to compare.
      tolerance - The tolerance of the closeness.
      Returns:
      true if the value is close to the DateValue parameter, false otherwise.
    • areClose

      public static boolean areClose(Value value, TimeValue expected, TimeValue tolerance)
      Returns if the value is close to the TimeValue in parameter with the tolerance in parameter.
      Parameters:
      value - The value.
      expected - The TimeValue to compare.
      tolerance - The tolerance of the closeness.
      Returns:
      true if the value is close to the TimeValue parameter, false otherwise.
    • areClose

      public static boolean areClose(Value value, DateTimeValue expected, DateValue tolerance)
      Returns if the value is close to the DateTimeValue in parameter with the tolerance in parameter.
      Parameters:
      value - The value.
      expected - The DateTimeValue to compare.
      tolerance - The tolerance of the closeness.
      Returns:
      true if the value is close to the DateTimeValue parameter, false otherwise.
    • areClose

      public static boolean areClose(Value value, DateTimeValue expected, TimeValue tolerance)
      Returns if the value is close to the DateTimeValue in parameter with the tolerance in parameter.
      Parameters:
      value - The value.
      expected - The DateTimeValue to compare.
      tolerance - The tolerance of the closeness.
      Returns:
      true if the value is close to the DateTimeValue parameter, false otherwise.
    • areClose

      public static boolean areClose(Value value, DateTimeValue expected, DateTimeValue tolerance)
      Returns if the value is close to the DateTimeValue in parameter with the tolerance in parameter.
      Parameters:
      value - The value.
      expected - The DateTimeValue to compare.
      tolerance - The tolerance of the closeness.
      Returns:
      true if the value is close to the DateTimeValue parameter, false otherwise.