/** * Construct a new immutable {@code PropertyValue} instance. * @param label The value for the {@code label} attribute * @param value The value for the {@code value} attribute * @return An immutable PropertyValue instance */ public static ConfigurationProperty.PropertyValue of(String label, String value) { return validate(new ImmutablePropertyValue(label, value)); }
/** * Builds a new {@link ConfigurationProperty.PropertyValue PropertyValue}. * @return An immutable instance of PropertyValue * @throws java.lang.IllegalStateException if any required attributes are missing */ public ConfigurationProperty.PropertyValue build() { return ImmutablePropertyValue.validate(new ImmutablePropertyValue(label, value)); } }
/** * This instance is equal to all instances of {@code ImmutablePropertyValue} that have equal attribute values. * @return {@code true} if {@code this} is equal to {@code another} instance */ @Override public boolean equals(@Nullable Object another) { if (this == another) return true; return another instanceof ImmutablePropertyValue && equalTo((ImmutablePropertyValue) another); }
/** * Copy the current immutable object by setting a value for the {@link ConfigurationProperty.PropertyValue#getLabel() label} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for label (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutablePropertyValue withLabel(String value) { if (Objects.equals(this.label, value)) return this; return validate(new ImmutablePropertyValue(value, this.value)); }
/** * Copy the current immutable object by setting a value for the {@link ConfigurationProperty.PropertyValue#getValue() value} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for value (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutablePropertyValue withValue(String value) { if (Objects.equals(this.value, value)) return this; return validate(new ImmutablePropertyValue(this.label, value)); }