Class GenericOperations

java.lang.Object
net.ssehub.easy.varModel.cstEvaluation.GenericOperations

public class GenericOperations extends Object
Generic operation implementation for the individual types. Testing shall happen along the operation defining types.
Author:
Holger Eichelberger
  • Field Details

  • Constructor Details

    • GenericOperations

      private GenericOperations()
      Prevents external instantiation.
  • Method Details

    • localeToString

      public static String localeToString(EvaluationAccessor accessor)
      Turns the locale of the accessor/context into a string.
      Parameters:
      accessor - the accessor
      Returns:
      the locale as string
    • register

      public static void register()
      Registers the defined operations.
    • equals

      static EvaluationAccessor equals(EvaluationAccessor operand, EvaluationAccessor[] arguments, boolean negate)
      Implements a generic equality operation for basic values (excluding compounds and containers).
      Parameters:
      operand - the operand value
      arguments - the argument values
      negate - whether the (boolean) result shall be negated
      Returns:
      a boolean value if equality can be evaluated, null else
    • equalsNull

      static final EvaluationAccessor equalsNull(Value operand, Value argument, EvaluationContext context, boolean negate)
      Implements a generic equality operation for null values.
      Parameters:
      operand - the operand value
      argument - the argument value
      context - the evaluation context
      negate - whether the (boolean) result shall be negated
      Returns:
      a boolean value if equality can be evaluated, null else
    • toType

      private static IDatatype toType(Value value)
      Returns the type of value.
      Parameters:
      value - the value to be turned into its type
      Returns:
      the type (may be null)
    • isAssignableCompound

      private static boolean isAssignableCompound(EvaluationAccessor operand)
      Returns true if EvaluationAccessor is a compound and all compounds nested elements are undefined.
      Parameters:
      operand - EvaluationAccessor to be checked.
      Returns:
      true if all nested elements are undefined.
    • assign

      private static EvaluationAccessor assign(EvaluationAccessor operand, EvaluationAccessor[] arguments, boolean asAssignment)
      Performs a value assignment.
      Parameters:
      operand - the operand
      arguments - the arguments
      asAssignment - called as part of an assignment (hard constraint, true) or as part of a soft constraint (false)
      Returns:
      the result evaluation accessor
    • checkDefined

      private static final EvaluationAccessor checkDefined(EvaluationAccessor operand, EvaluationAccessor[] arguments, boolean lazy)
      Common implementation of isDefined/ifDefined.
      Parameters:
      operand - the operand
      arguments - the operation arguments
      lazy - whether an undefined, so far assigned variable causes an error (false) or not (lazy, true)
      Returns:
      the evaluation result, may be null for undefined