/** * Copy the current immutable object by setting a value for the {@link Violation#property() property} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for property (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableViolation withProperty(String value) { if (Objects.equals(this.property, value)) return this; return validate(new ImmutableViolation(this.error, this.message, value)); }
/** * Copy the current immutable object by setting a value for the {@link Violation#message() message} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for message (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableViolation withMessage(String value) { if (Objects.equals(this.message, value)) return this; return validate(new ImmutableViolation(this.error, value, this.property)); }
/** * Construct a new immutable {@code Violation} instance. * @param error The value for the {@code error} attribute * @param message The value for the {@code message} attribute * @param property The value for the {@code property} attribute * @return An immutable Violation instance */ public static Violation of(String error, String message, String property) { return validate(new ImmutableViolation(error, message, property)); }
/** * Copy the current immutable object by setting a value for the {@link Violation#error() error} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for error (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableViolation withError(String value) { if (Objects.equals(this.error, value)) return this; return validate(new ImmutableViolation(value, this.message, this.property)); }