/** * Construct a new immutable {@code Dependency} instance. * @param type The value for the {@code type} attribute * @param id The value for the {@code id} attribute * @return An immutable Dependency instance */ public static Dependency of(Dependency.Type type, String id) { return validate(new ImmutableDependency(type, id)); }
/** * Builds a new {@link Dependency Dependency}. * @return An immutable instance of Dependency * @throws java.lang.IllegalStateException if any required attributes are missing */ public Dependency build() { return ImmutableDependency.validate(new ImmutableDependency(type, id)); } }
/** * This instance is equal to all instances of {@code ImmutableDependency} 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 ImmutableDependency && equalTo((ImmutableDependency) another); }
/** * Copy the current immutable object by setting a value for the {@link Dependency#getType() type} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for type (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableDependency withType(Dependency.Type value) { if (this.type == value) return this; return validate(new ImmutableDependency(value, this.id)); }
/** * Copy the current immutable object by setting a value for the {@link Dependency#getId() id} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for id (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableDependency withId(String value) { if (Objects.equals(this.id, value)) return this; return validate(new ImmutableDependency(this.type, value)); }