Exemplo n.º 1
0
 /**
  * Checks for duplicates within {@link #variableValue}. This is a workaround for the problem that
  * container values currently do not check for duplicate values while adding/setting values.
  *
  * @param value the new value
  * @param allowedPos an allowed position in case of value replacements, may be negative in order
  *     to indicate that there is no such position
  * @throws ValueDoesNotMatchTypeException in case of a duplicate in a Set
  */
 private void checkForDuplicates(Value value, int allowedPos)
     throws ValueDoesNotMatchTypeException {
   if (null != variableValue
       && Set.TYPE.isAssignableFrom(getVariable().getDeclaration().getType())) {
     int index = variableValue.indexOf(value);
     if (index >= 0) {
       if (allowedPos < 0 || index != allowedPos) {
         throw new ValueDoesNotMatchTypeException(
             "Duplicate constraint is not allowed",
             ValueDoesNotMatchTypeException.NOT_ALLOWED_VALUE_STRUCTURE);
       }
     }
   }
 }