/** * Builds a new {@link PropertyRelation PropertyRelation}. * @return An immutable instance of PropertyRelation * @throws java.lang.IllegalStateException if any required attributes are missing */ public PropertyRelation build() { return ImmutablePropertyRelation.validate(new ImmutablePropertyRelation(null, action, createUnmodifiableList(true, when))); } }
/** * Copy the current immutable object by setting a value for the {@link PropertyRelation#getAction() action} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for action (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutablePropertyRelation withAction(String value) { if (Objects.equals(this.action, value)) return this; return validate(new ImmutablePropertyRelation(this, value, this.when)); }
/** * Construct a new immutable {@code PropertyRelation} instance. * @param action The value for the {@code action} attribute * @param when The value for the {@code when} attribute * @return An immutable PropertyRelation instance */ public static PropertyRelation of(String action, Iterable<? extends PropertyRelation.When> when) { return validate(new ImmutablePropertyRelation(action, when)); }
/** * Copy the current immutable object with elements that replace the content of {@link PropertyRelation#getWhen() when}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final ImmutablePropertyRelation withWhen(PropertyRelation.When... elements) { List<PropertyRelation.When> newValue = createUnmodifiableList(false, createSafeList(Arrays.asList(elements), true, false)); return validate(new ImmutablePropertyRelation(this, this.action, newValue)); }
/** * Copy the current immutable object with elements that replace the content of {@link PropertyRelation#getWhen() when}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of when elements to set * @return A modified copy of {@code this} object */ public final ImmutablePropertyRelation withWhen(Iterable<? extends PropertyRelation.When> elements) { if (this.when == elements) return this; List<PropertyRelation.When> newValue = createUnmodifiableList(false, createSafeList(elements, true, false)); return validate(new ImmutablePropertyRelation(this, this.action, newValue)); }