/** * An {@code int} specialized version of {@link #checkPostcondition(Object, * ContractConditionType)}. * * @param value The value * @param condition The predicate * * @return value * * @throws PostconditionViolationException If the predicate is false */ public static int checkPostconditionI( final int value, final ContractIntConditionType condition) throws PostconditionViolationException { return checkPostconditionI( value, condition.predicate(), condition.describer()); }
/** * An {@code int} specialized version of {@link #checkInvariant(Object, * ContractConditionType)}. * * @param value The value * @param condition The predicate * * @return value * * @throws InvariantViolationException If the predicate is false */ public static int checkInvariantI( final int value, final ContractIntConditionType condition) throws InvariantViolationException { return checkInvariantI( value, condition.predicate(), condition.describer()); }
/** * An {@code int} specialized version of {@link #checkPrecondition(Object, * ContractConditionType)}. * * @param value The value * @param condition The predicate * * @return value * * @throws PreconditionViolationException If the predicate is false */ public static int checkPreconditionI( final int value, final ContractIntConditionType condition) throws PreconditionViolationException { return checkPreconditionI( value, condition.predicate(), condition.describer()); }
/** * An {@code int} specialized version of {@link #checkInvariant(Object, * ContractConditionType)}. * * @param value The value * @param condition The predicate * * @return value * * @throws InvariantViolationException If the predicate is false */ public static int checkInvariantI( final int value, final ContractIntConditionType condition) throws InvariantViolationException { return checkInvariantI( value, condition.predicate(), condition.describer()); }
/** * An {@code int} specialized version of {@link #checkPostcondition(Object, * ContractConditionType)}. * * @param value The value * @param condition The predicate * * @return value * * @throws PostconditionViolationException If the predicate is false */ public static int checkPostconditionI( final int value, final ContractIntConditionType condition) throws PostconditionViolationException { return checkPostconditionI( value, condition.predicate(), condition.describer()); }
/** * An {@code int} specialized version of {@link #checkPrecondition(Object, * ContractConditionType)}. * * @param value The value * @param condition The predicate * * @return value * * @throws PreconditionViolationException If the predicate is false */ public static int checkPreconditionI( final int value, final ContractIntConditionType condition) throws PreconditionViolationException { return checkPreconditionI( value, condition.predicate(), condition.describer()); }
/** * Fill a builder with attribute values from the provided {@code ContractIntConditionType} instance. * Regular attribute values will be replaced with those from the given instance. * Absent optional values will not replace present values. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Builder from(ContractIntConditionType instance) { Objects.requireNonNull(instance, "instance"); setPredicate(instance.predicate()); setDescriber(instance.describer()); return this; }
/** * Fill a builder with attribute values from the provided {@code ContractIntConditionType} instance. * Regular attribute values will be replaced with those from the given instance. * Absent optional values will not replace present values. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Builder from(ContractIntConditionType instance) { Objects.requireNonNull(instance, "instance"); setPredicate(instance.predicate()); setDescriber(instance.describer()); return this; }
static Violations innerCheckAllInt( final int value, final ContractIntConditionType[] conditions) { Violations violations = null; for (int index = 0; index < conditions.length; ++index) { final ContractIntConditionType condition = conditions[index]; final IntPredicate predicate = condition.predicate(); final boolean ok; final int count = conditions.length; try { ok = predicate.test(value); } catch (final Throwable e) { violations = maybeAllocate(violations, count); violations.messages()[index] = failedPredicate(e); violations.countUp(); continue; } if (!ok) { violations = maybeAllocate(violations, count); violations.messages()[index] = applyDescriberIChecked(value, condition.describer()); violations.countUp(); } } return violations; }
static Violations innerCheckAllInt( final int value, final ContractIntConditionType[] conditions) { Violations violations = null; for (int index = 0; index < conditions.length; ++index) { final ContractIntConditionType condition = conditions[index]; final IntPredicate predicate = condition.predicate(); final boolean ok; final int count = conditions.length; try { ok = predicate.test(value); } catch (final Throwable e) { violations = maybeAllocate(violations, count); violations.messages()[index] = failedPredicate(e); violations.countUp(); continue; } if (!ok) { violations = maybeAllocate(violations, count); violations.messages()[index] = applyDescriberIChecked(value, condition.describer()); violations.countUp(); } } return violations; }