/*
Adds a constraint to the map of constraints if a value is given. Does not create the map
or a constraint if not needed.

@param {string} sKey The constraint's name
@param {any} vValue The contraint's value
501878
function setConstraint(sKey, vValue) {
			if (vValue !== undefined) {
				mConstraints = mConstraints || {};
				mConstraints[sKey] = vValue;
			}
		}
1157902
private void updateVertexProperty(AtlasVertex vertex, String propertyName, String newValue) {
        if (StringUtils.isNotBlank(newValue)) {
            String currValue = vertex.getProperty(propertyName, String.class);

            if (!StringUtils.equals(currValue, newValue)) {
                vertex.setProperty(propertyName, newValue);
            }
        }
    }
171383
@Override
  public final boolean isValid(final Object pvalue, final ConstraintValidatorContext pcontext) {
    final String valueAsString;
    if (ignoreWhitspaces) {
      valueAsString =
          Objects.toString(pvalue, StringUtils.EMPTY).replaceAll("\\s+", StringUtils.EMPTY);
    } else {
      valueAsString = Objects.toString(pvalue, null);
    }
    if (StringUtils.isEmpty(valueAsString)) {
      // empty field is ok
      return true;
    }
    if (valueAsString.length() != BIC_LENGTH_MIN && valueAsString.length() != BIC_LENGTH_MAX) {
      // to short or to long, but it's handled by size validator!
      return true;
    }
    if (!valueAsString.matches(BIC_REGEX)) {
      // format is wrong!
      return false;
    }
    final String countryCode = valueAsString.substring(4, 6);
    final IbanLengthDefinition validBicLength = IBAN_LENGTH_MAP.ibanLengths().get(countryCode);

    return validBicLength != null;
  }
686859
function compile_constraints(request, constraints) {
  const Constraints = require("./constraints")
  
  // Exit if there aren't any constraints.
  if (!constraints)
    return {}

  return new Constraints()
    .set_source(request)
    .set_rules(constraints)
    .compile()
    .results
}
532858
@Nonnull
  public FineUploader5DeleteFile addParam (@Nonnull @Nonempty final String sKey, @Nonnull final String sValue)
  {
    ValueEnforcer.notEmpty (sKey, "Key");
    ValueEnforcer.notNull (sValue, "Value");

    m_aDeleteFileParams.put (sKey, sValue);
    return this;
  }
1124594
def add_constraint(self, op, val):
        
        if len(self.constraints) > 0:
            if op.is_equality():
                clist = ', '.join(map(str, self.constraints))
                raise ValueError('Field {}: equality operator cannot be combined '
                                 'with others: {}'.format(self._field.name, clist))
            elif op.is_exists():
                raise ValueError('Field {}: existence is implied '
                                 'by other operators'.format(self._field.name))
        constraint = Constraint(self._field, op, val)
        self.constraints.append(constraint)
        if self._field.has_subfield():
            self._array = True
        elif op.is_inequality():
            self._range = True
1223168
private void addConstraintNameToList(String constraintName) {
		validateStringValue(constraintName);
		Set<String> currentValues = getConstraintNameList();
		currentValues.add(constraintName);
		setProperty(ConstraintContextProperty.ALL_CONSTRAINTS, ArrayUtils.toString(currentValues.toArray()));
	}
1326957
@Override
  public final boolean isValid(final Object pvalue, final ConstraintValidatorContext pcontext) {
    final String valueAsString = Objects.toString(pvalue, null);
    if (StringUtils.isEmpty(valueAsString)) {
      return true;
    }
    if (!StringUtils.isNumeric(valueAsString)) {
      // EAN must be numeric, but that's handled by digits annotation
      return true;
    }
    if (valueAsString.length() != Gtin8Validator.GTIN8_LENGTH
        && valueAsString.length() != Gtin13Validator.GTIN13_LENGTH) {
      // EAN size is wrong, but that's handled by alternate size annotation
      return true;
    }
    // calculate and check checksum (GTIN/EAN)
    return CHECK_GTIN.isValid(valueAsString);
  }
766055
void add( K key, V value ) {
        List<V> rules = map.get( key );
        if( rules == null ) {
            rules = new ArrayList<>();
            map.put( key, rules );
        }
        rules.add( value );
    }
278526
public void addConstraint( final FieldConstraint constraint ) {
        if ( this.constraints == null ) {
            this.constraints = new FieldConstraint[ 1 ];
            this.constraints[ 0 ] = constraint;
        } else {
            final FieldConstraint[] newList = new FieldConstraint[ this.constraints.length + 1 ];
            for ( int i = 0; i < this.constraints.length; i++ ) {
                newList[ i ] = this.constraints[ i ];
            }
            newList[ this.constraints.length ] = constraint;
            this.constraints = newList;
        }
    }
571797
function (x, y) {
        var self = this;

        // TODO: Move this to some global class
        function constrain(value, max, size) {
          if (value < 0) {
            return 0;
          }

          if (value + size > max) {
            value = max - size;
            return value < 0 ? 0 : value;
          }

          return value;
        }

        if (self.settings.constrainToViewport) {
          var viewPortRect = DomUtils.getViewPort(window);
          var layoutRect = self.layoutRect();

          x = constrain(x, viewPortRect.w + viewPortRect.x, layoutRect.w);
          y = constrain(y, viewPortRect.h + viewPortRect.y, layoutRect.h);
        }

        if (self.state.get('rendered')) {
          self.layoutRect({ x: x, y: y }).repaint();
        } else {
          self.settings.x = x;
          self.settings.y = y;
        }

        self.fire('move', { x: x, y: y });

        return self;
      }
649174
protected function putDefaultStorageValue($sKey, $obValue)
    {
        if (empty($this->obDefaultStorage)) {
            return;
        }

        $this->obDefaultStorage->put($sKey, $obValue);
    }
514537
public void put(K key,V value){
		List<V> list;
		if (map.containsKey(key)){
			list=(List<V>)map.get(key);
		} else {
			list=new Vector<V>();
			map.put(key,list);
		}		
		list.add(value);		
	}
1313687
function validateProperty(object, value, property, schema, options, errors, indexInArray, array) {
    var valid,
        type;

    function constrain(name, value, assert) {
      if (schema[name] !== undefined && !assert(value, schema[name])) {
        error(name, property, value, schema, errors);
      }
    }

    //validate default value
    if (options.validateDefaultValue && schema['default'] !== undefined &&
        property != 'default') {
      validateProperty(schema, schema['default'], 'default', schema, options, errors);
    }

    if (value === undefined) {
      //apply default value if have an option and default value
      if (options.applyDefaultValue && schema['default'] !== undefined) {
        value = schema['default'];
        object[property] = value;
        return;
      } else if (schema.required) {
        var required = schema.required;
        if (typeof required === 'function') {
          required = required(object, property);
        }
        if (required && schema.type !== 'any') {
          return error('required', property, undefined, schema, errors);
        } else {
          return;
        }
      } else {
        return;
      }
    }

    if (options.cast) {
      if (('integer' === schema.type || 'number' === schema.type) && value == +value) {
        value = +value;
      }

      if ('boolean' === schema.type) {
        if ('true' === value || '1' === value || 1 === value) {
          value = true;
        }

        if ('false' === value || '0' === value || 0 === value) {
          value = false;
        }
      }

      if ('date' === schema.type) {
        value = new Date(value);
      }
      //modify source object if we have an option and values are differ
      //for simple value
      if (options.castSource && indexInArray == null && object[property] !== value) {
        object[property] = value;
      } else
        if (options.castSource && indexInArray != null && array[indexInArray] !== value) {
          //and for an array
          array[indexInArray] = value;
        }
    }

    if (schema['enum'] && schema['enum'].indexOf(value) === -1) {
      error('enum', property, value, schema, errors);
    }

    // Dependencies (see 5.8)
    if (typeof schema.dependencies === 'string' &&
        object[schema.dependencies] === undefined) {
      error('dependencies', property, null, schema, errors);
    }

    if (isArray(schema.dependencies)) {
      for (var i = 0, l = schema.dependencies.length; i < l; i++) {
        if (object[schema.dependencies[i]] === undefined) {
          error('dependencies', property, null, schema, errors);
        }
      }
    }

    if (typeof schema.dependencies === 'object') {
      var oldAdditionalProperties = options.additionalProperties;
      options.additionalProperties = true;
      validateObject(object, schema.dependencies, options, errors);
      options.additionalProperties = oldAdditionalProperties;
    }

    checkType(value, schema.type, function(err, type) {
      var errorsCountBeforeCheckType = errors.length;
      if (err) return error('type', property, typeof value, schema, errors);

      constrain('conform', value, function (a, e) { return e(a, object, property) });

      switch (type || (isArray(value) ? 'array' : typeof value)) {
        case 'string':
          constrain('minLength', value.length, function (a, e) { return a >= e });
          constrain('maxLength', value.length, function (a, e) { return a <= e });
          constrain('pattern',   value,        function (a, e) {
            e = typeof e === 'string'
              ? e = new RegExp(e)
              : e;
            return e.test(a)
          });
          if (options.validateFormats) {
            constrain('format', value, function(value, format) {
              var spec;
              if (options.validateFormatExtensions) {
                spec = validate.formatExtensions[format];
              }
              if (!spec) {
                spec = validate.formats[format];
              }
              if (spec) {
                return spec.test(value);
              } else {
                return !options.validateFormatsStrict;
              }
            });
          }
          break;
        case 'integer':
        case 'number':
          constrain('minimum',     value, function (a, e) { return a >= e });
          constrain('maximum',     value, function (a, e) { return a <= e });
          constrain('exclusiveMinimum', value, function (a, e) { return a > e });
          constrain('exclusiveMaximum', value, function (a, e) { return a < e });
          constrain('divisibleBy', value, function (a, e) {
            var multiplier = Math.max((a - Math.floor(a)).toString().length - 2, (e - Math.floor(e)).toString().length - 2);
            multiplier = multiplier > 0 ? Math.pow(10, multiplier) : 1;
            return (a * multiplier) % (e * multiplier) === 0
          });
          break;
        case 'array':
          constrain('items', value, function (a, e) {
            for (var i = 0, l = a.length; i < l; i++) {
              validateProperty(object, a[i], property, e, options, errors, i, a);
            }
            return true;
          });
          constrain('minItems', value, function (a, e) { return a.length >= e });
          constrain('maxItems', value, function (a, e) { return a.length <= e });
          constrain('uniqueItems', value, function (a) {
            var h = {};

            for (var i = 0, l = a.length; i < l; i++) {
              var key = JSON.stringify(a[i]);
              if (h[key]) return false;
              h[key] = true;
            }

            return true;
          });
          break;
        case 'object':
          // Recursive validation
          if (schema.properties || schema.patternProperties || schema.additionalProperties) {
            validateObject(value, schema, options, errors);
          }
          break;
      }

      //schema filtering
      if (schema.filter && errorsCountBeforeCheckType == errors.length) {
        if (type != 'array' && type != 'object') {
          var filters = isArray(schema.filter) ? schema.filter : [schema.filter];
          for (var i = 0, l = filters.length; i < l; i++) {
            var filter = null;
            if (isString(filters[i])) {
              if (filters[i] in validate.filters) {
                filter = validate.filters[filters[i]];
              } else {
                return error('filter', property, filters[i], schema, errors, 'unknown filter: %{actual}');
              }
            } else if (isFunction(filters[i])) {
              filter = filters[i];
            } else {
              return error('filter', property, typeof filters[i], schema, errors, 'bad filter type: %{actual}');
            }
            try {
              // filter value for simple value or for an array item
              if (indexInArray == null) {
                object[property] = filter(object[property]);  
              } else {
                object[property][indexInArray] = filter(object[property][indexInArray]);
              }
            } catch(err) {
              return error('filter', property, err, schema, errors, 'error during filtering: %{actual}');
            }
          }
        } else {
          return error('filter', property, type, schema, errors, 'bad property type for filtering: %{actual}');
        }
      }
    });
  }
513776
def define(self, key, value):
        
        skey = nstr(key)
        self._defaults[skey] = value
        self[skey] = value
342238
private boolean checkValueConstraints(int requiredType, String[] constraints, Value value)
   {
      ValueConstraintsMatcher constrMatcher =
         new ValueConstraintsMatcher(constraints, locationFactory, dataManager, nodeTypeDataManager);

      try
      {
         return constrMatcher.match(((BaseValue)value).getInternalData(), requiredType);
      }
      catch (RepositoryException e1)
      {
         return false;
      }
   }
1052907
protected T resolve(String sKey, T value) {
        LOG.error("Fail to find environment [{}] in {}", sKey, this.keySet());
        throw new MultiEnvSupportException(String.format(
                "Fail to find configuration for environment %s", sKey));
    }