Check __construct method constraints.

@throws ImmutabilityViolationException
8651
private function checkCallConstraints(): void
    {
        if ($this->alreadyConstructed) {
            throw new ImmutabilityViolationException(\sprintf(
                'Class %s constructor was already called',
                static::class
            ));
        }

        $stack = \debug_backtrace();
        while (\count($stack) > 0 && $stack[0]['function'] !== 'checkImmutability') {
            \array_shift($stack);
        }

        if (!isset($stack[1]) || $stack[1]['function'] !== '__construct') {
            throw new ImmutabilityViolationException(\sprintf(
                'Immutability check can only be called from constructor, called from %s::%s',
                static::class,
                $stack[1]['function']
            ));
        }

        $this->alreadyConstructed = true;
    }
1217602
function constraintsRepr(
    constraints,    // :: StrMap (Array TypeClass)
    outer,          // :: String -> String
    inner           // :: String -> TypeClass -> String -> String
  ) {
    var $reprs = [];
    (sortedKeys (constraints)).forEach (function(k) {
      var f = inner (k);
      constraints[k].forEach (function(typeClass) {
        $reprs.push (f (typeClass) (stripNamespace (typeClass) + ' ' + k));
      });
    });
    return when ($reprs.length > 0)
                (wrap ('') (outer (' => ')))
                (when ($reprs.length > 1)
                      (parenthesize (outer))
                      (joinWith (outer (', '), $reprs)));
  }
498358
def check_constraint(self, pkge=None, constr=None):
        
        if not pkge is None:
            return javabridge.call(
                self.jobject, "checkConstraint", "(Lweka/core/packageManagement/Package;)Z", pkge.jobject)
        if not constr is None:
            return javabridge.call(
                self.jobject, "checkConstraint", "(Lweka/core/packageManagement/PackageConstraint;)Z", pkge.jobject)
        raise Exception("Either package or package constraing must be provided!")
929080
public void checkConstraints(String checkLevel) throws ConstraintException
    {
        // now checking constraints
        FieldDescriptorConstraints      fieldConstraints = new FieldDescriptorConstraints();
        ReferenceDescriptorConstraints  refConstraints   = new ReferenceDescriptorConstraints();
        CollectionDescriptorConstraints collConstraints  = new CollectionDescriptorConstraints();

        for (Iterator it = getFields(); it.hasNext();)
        {
            fieldConstraints.check((FieldDescriptorDef)it.next(), checkLevel);
        }
        for (Iterator it = getReferences(); it.hasNext();)
        {
            refConstraints.check((ReferenceDescriptorDef)it.next(), checkLevel);
        }
        for (Iterator it = getCollections(); it.hasNext();)
        {
            collConstraints.check((CollectionDescriptorDef)it.next(), checkLevel);
        }
        new ClassDescriptorConstraints().check(this, checkLevel);
    }
1293594
private void check() {
		final Constructor<?> constructor = getConstructor();
		final XParameter[] parameters = getParameters();
		final Class<?>[] parameterTypes = constructor.getParameterTypes();
		Validate.isTrue(parameters.length == parameterTypes.length,
				"Wrong number of parameters: [" + parameters.length
						+ "], expected [" + parameterTypes.length + "].");
		for (int index = 0; index < parameters.length; index++) {
			final XParameter parameter = parameters[index];
			final Class<?> parameterType = parameterTypes[index];
			Validate.isTrue(parameterType.equals(parameter.getType()),
					"Wrong parameter type: [" + parameter.getType()
							+ "], expected [" + parameterType + "]");
		}
	}
313646
public static ConstraintViolationException instantiate(
      final SerializationStreamReader streamReader) throws SerializationException {
    final String message = streamReader.readString();
    @SuppressWarnings("unchecked")
    final Set<ConstraintViolation<?>> set = (Set<ConstraintViolation<?>>) streamReader.readObject();
    return new ConstraintViolationException(message, set);
  }
1251150
@VisibleForTesting
  URIBuilder constraints(Constraints constraints) {
    options.putAll(constraints.toQueryMap());
    this.isView = !constraints.isUnbounded();
    return this;
  }
185765
public static <T> Constraint
            checking(Function<String, T> check, String messageOrKey, boolean isKey, String... extraMessageArgs) {
        return mkSimpleConstraint(((label, vString, messages) -> {
            logger.debug("checking for {}", vString);

            if (isEmptyStr(vString)) return null;
            else {
                try {
                    check.apply(vString);
                    return null;
                } catch (Exception ex) {
                    String msgTemplate = isKey ? messages.get(messageOrKey) : messageOrKey;
                    List<String> messageArgs = appendList(Arrays.asList(vString), extraMessageArgs);
                    return String.format(msgTemplate, messageArgs.toArray());
                }
            }
        }), null);
    }
189620
public void check()
        throws FatalCompileTimeException
    {
        HashSet declsToCheck = new HashSet();

        //
        // First, build up the Set of declarations to check.  We don't want any duplicates.
        //
        for ( int i = 0; i < _atds.length; ++i )
        {
            AnnotationTypeDeclaration atd = _atds[i];
            Declaration[] decls = getAnnotationProcessorEnvironment().getDeclarationsAnnotatedWith( atd );
            for ( int j = 0; j < decls.length; j++ )
            {
                declsToCheck.add( decls[j] );
            }
        }

        // Now, check the declarations.
        check(declsToCheck);
    }
63555
void enforceRowConstraints(Session session, Object[] data) {

        for (int i = 0; i < defaultColumnMap.length; i++) {
            Type type = colTypes[i];

            data[i] = type.convertToTypeLimits(session, data[i]);

            if (type.isDomainType()) {
                Constraint[] constraints =
                    type.userTypeModifier.getConstraints();

                for (int j = 0; j < constraints.length; j++) {
                    constraints[j].checkCheckConstraint(session, this,
                                                        data[i]);
                }
            }

            if (data[i] == null) {
                if (colNotNull[i]) {
                    Constraint c = getNotNullConstraintForColumn(i);

                    if (c == null) {
                        if (getColumn(i).isPrimaryKey()) {
                            c = this.getPrimaryConstraint();
                        }
                    }

                    String[] info = new String[] {
                        c.getName().name, tableName.name
                    };

                    throw Error.error(ErrorCode.X_23503, ErrorCode.CONSTRAINT,
                                      info);
                }
            }
        }
    }
964698
@Before
    static void checkRestrictions() throws Throwable
    {
        DEADBOLT_HANDLER.beforeRoleCheck();

        RoleHolder roleHolder = getRoleHolder();
        RestrictionType restrictionType = getRestrictionType();
        if (restrictionType == RestrictionType.DYNAMIC)
        {
            handleDynamicChecks(roleHolder);
        }
        else if (restrictionType == RestrictionType.STATIC)
        {
            handleStaticChecks(roleHolder);
        }
        else if (restrictionType == RestrictionType.BASIC)
        {
            handleRoleHolderPresent(roleHolder);
        }
    }
1187190
public void check(Declaration decl, AnnotationProcessorEnvironment env) {

        _locale = Locale.getDefault();

        if (decl instanceof TypeDeclaration) {

            //
            // Check method annotations
            //
            Collection<? extends MethodDeclaration> methods = ((TypeDeclaration) decl).getMethods();
            for (MethodDeclaration method : methods) {
                checkSQL(method, env);

            }
        } else if (decl instanceof FieldDeclaration) {

            //
            // NOOP
            //
        } else {

            //
            // NOOP
            //
        }
    }
1047546
def add_constraints(constrs)
      start, index, value = build_constraint_matrix constrs
      start_buffer = build_pointer_array start, :int
      index_buffer = build_pointer_array index, :int
      value_buffer = build_pointer_array value, :double

      Cbc.Cbc_loadProblem @ptr, @variables.length, constrs.length,
                          start_buffer, index_buffer, value_buffer,
                          nil, nil, nil, nil, nil

      store_model constrs, @variables
    end
922460
public void checkExpectedValidationViolations(
			Set<ConstraintViolation<T>> violations,
			List<String> expectedValidationViolations) {

		if (violations != null && expectedValidationViolations != null) {

			List<String> givenViolations = new ArrayList<String>();
			for (ConstraintViolation<T> violation : violations) {
				givenViolations.add(violation.getMessageTemplate());
			}

			checkViolations(givenViolations, expectedValidationViolations);
		}

	}
1096331
private void validateConstraint(RuleSet ruleSet, Constraint constraint, Severity severity) throws RuleException {
        if (!executedConstraints.contains(constraint)) {
            if (applyRequiredConcepts(ruleSet, constraint)) {
                ruleVisitor.visitConstraint(constraint, severity);
            } else {
                ruleVisitor.skipConstraint(constraint, severity);
            }
            executedConstraints.add(constraint);
        }
    }
1106683
private static function bindViolations(ConstraintViolationList $violations, ServiceBusContext $context): void
    {
        $errors = [];

        /** @var \Symfony\Component\Validator\ConstraintViolation $violation */
        foreach ($violations as $violation)
        {
            $errors[$violation->getPropertyPath()][] = $violation->getMessage();
        }

        try
        {
            invokeReflectionMethod($context, 'validationFailed', $errors);
        }
        // @codeCoverageIgnoreStart
        catch (\Throwable $throwable)
        {
            /** No exceptions can happen */
        }
        // @codeCoverageIgnoreEnd
    }
585761
public Constraint method(Object target, String methodName, String constraintType) {
        return new MethodInvokingConstraint(target, methodName, constraintType);
    }