class MyAttributeValueFactory {

  public static boolean evaulateFunction(URI function, List<MyAttributeValue> arguments) {
    String returnType = returnTypeOfFunction(function);
    if(!checkTypes(arguments, returnType)) {
      throw new RuntimeException("Incorrect type of arguments, when evaluating function: '"
        + function + "'");
    }
    OperationType op = operationTypeOfFunction(function);
    if (!isArgumentNumberCorrect(op, arguments.size())) {
      throw new RuntimeException("Incorrect number of arguments when evaluating function: '"
          + function + "'");
    }
    switch (op) {
      case EQUAL:
        return arguments.get(0).isCompatibleAndEquals(arguments.get(1));
      case NOTEQUAL:
        return arguments.get(0).isCompatibleAndNotEquals(arguments.get(1));
      case EQUALONEOF: {
        MyAttributeValue first = arguments.get(0);
        for (int i = 1; i < arguments.size(); ++i) {
          if (first.isCompatibleAndEquals(arguments.get(i))) {
            return true;
          }
        }
        return false;
      }
      case LESS:
        return arguments.get(0).isCompatibleAndLess(arguments.get(1));
      case LESSEQ:
        return arguments.get(0).isCompatibleAndLessOrEqual(arguments.get(1));
      case GREATER:
        return arguments.get(1).isCompatibleAndLess(arguments.get(0));
      case GREATEREQ:
        return arguments.get(1).isCompatibleAndLessOrEqual(arguments.get(0));
      default:
        throw new RuntimeException("Problem with evaluating function: '" + function + "'");
    }
  }

}