/** * Copy the current immutable object with elements that replace the content of {@link CItemType#tickets() tickets}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of tickets elements to set * @return A modified copy of {@code this} object */ public final CItem withTickets(Iterable<String> elements) { if (this.tickets == elements) return this; List<String> newValue = createUnmodifiableList(false, createSafeList(elements, true, false)); return new CItem(this, this.date, this.summary, newValue, this.type); }
/** * This instance is equal to all instances of {@code CItem} that have equal attribute values. * @return {@code true} if {@code this} is equal to {@code another} instance */ @Override public boolean equals(Object another) { if (this == another) return true; return another instanceof CItem && equalTo((CItem) another); }
/** * Construct a new immutable {@code CItem} instance. * @param date The value for the {@code date} attribute * @param summary The value for the {@code summary} attribute * @param tickets The value for the {@code tickets} attribute * @param type The value for the {@code type} attribute * @return An immutable CItem instance */ public static CItem of(LocalDate date, String summary, List<String> tickets, CChangeType type) { return of(date, summary, (Iterable<String>) tickets, type); }
/** * Construct a new immutable {@code CItem} instance. * @param date The value for the {@code date} attribute * @param summary The value for the {@code summary} attribute * @param tickets The value for the {@code tickets} attribute * @param type The value for the {@code type} attribute * @return An immutable CItem instance */ public static CItem of(LocalDate date, String summary, Iterable<String> tickets, CChangeType type) { return new CItem(date, summary, tickets, type); }
private CItem( LocalDate date, String summary, Iterable<String> tickets, CChangeType type) { this.date = Objects.requireNonNull(date, "date"); this.summary = Objects.requireNonNull(summary, "summary"); this.tickets = createUnmodifiableList(false, createSafeList(tickets, true, false)); this.type = Objects.requireNonNull(type, "type"); }
/** * Creates an immutable copy of a {@link CItemType} value. * Uses accessors to get values to initialize the new immutable instance. * If an instance is already immutable, it is returned as is. * @param instance The instance to copy * @return A copied immutable CItem instance */ public static CItem copyOf(CItemType instance) { if (instance instanceof CItem) { return (CItem) instance; } return CItem.builder() .from(instance) .build(); }
/** * Construct a new immutable {@code CItem} instance. * @param date The value for the {@code date} attribute * @param summary The value for the {@code summary} attribute * @param tickets The value for the {@code tickets} attribute * @param type The value for the {@code type} attribute * @return An immutable CItem instance */ public static CItem of(LocalDate date, String summary, Iterable<String> tickets, CChangeType type) { return new CItem(date, summary, tickets, type); }
private CItem( LocalDate date, String summary, Iterable<String> tickets, CChangeType type) { this.date = Objects.requireNonNull(date, "date"); this.summary = Objects.requireNonNull(summary, "summary"); this.tickets = createUnmodifiableList(false, createSafeList(tickets, true, false)); this.type = Objects.requireNonNull(type, "type"); }
/** * Creates an immutable copy of a {@link CItemType} value. * Uses accessors to get values to initialize the new immutable instance. * If an instance is already immutable, it is returned as is. * @param instance The instance to copy * @return A copied immutable CItem instance */ public static CItem copyOf(CItemType instance) { if (instance instanceof CItem) { return (CItem) instance; } return CItem.builder() .from(instance) .build(); }
/** * Copy the current immutable object with elements that replace the content of {@link CItemType#tickets() tickets}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of tickets elements to set * @return A modified copy of {@code this} object */ public final CItem withTickets(Iterable<String> elements) { if (this.tickets == elements) return this; List<String> newValue = createUnmodifiableList(false, createSafeList(elements, true, false)); return new CItem(this, this.date, this.summary, newValue, this.type); }
/** * Copy the current immutable object by setting a value for the {@link CItemType#type() 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 * @return A modified copy of the {@code this} object */ public final CItem withType(CChangeType value) { if (this.type == value) return this; CChangeType newValue = Objects.requireNonNull(value, "type"); return new CItem(this, this.date, this.summary, this.tickets, newValue); }
/** * Construct a new immutable {@code CItem} instance. * @param date The value for the {@code date} attribute * @param summary The value for the {@code summary} attribute * @param tickets The value for the {@code tickets} attribute * @param type The value for the {@code type} attribute * @return An immutable CItem instance */ public static CItem of(LocalDate date, String summary, List<String> tickets, CChangeType type) { return of(date, summary, (Iterable<String>) tickets, type); }
/** * This instance is equal to all instances of {@code CItem} that have equal attribute values. * @return {@code true} if {@code this} is equal to {@code another} instance */ @Override public boolean equals(Object another) { if (this == another) return true; return another instanceof CItem && equalTo((CItem) another); }
/** * Copy the current immutable object with elements that replace the content of {@link CItemType#tickets() tickets}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final CItem withTickets(String... elements) { List<String> newValue = createUnmodifiableList(false, createSafeList(Arrays.asList(elements), true, false)); return new CItem(this, this.date, this.summary, newValue, this.type); }
/** * Copy the current immutable object by setting a value for the {@link CItemType#date() date} attribute. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for date * @return A modified copy of the {@code this} object */ public final CItem withDate(LocalDate value) { if (this.date == value) return this; LocalDate newValue = Objects.requireNonNull(value, "date"); return new CItem(this, newValue, this.summary, this.tickets, this.type); }
/** * Copy the current immutable object with elements that replace the content of {@link CItemType#tickets() tickets}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final CItem withTickets(String... elements) { List<String> newValue = createUnmodifiableList(false, createSafeList(Arrays.asList(elements), true, false)); return new CItem(this, this.date, this.summary, newValue, this.type); }
/** * Copy the current immutable object by setting a value for the {@link CItemType#type() type} attribute. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for type * @return A modified copy of the {@code this} object */ public final CItem withType(CChangeType value) { if (this.type == value) return this; CChangeType newValue = Objects.requireNonNull(value, "type"); return new CItem(this, this.date, this.summary, this.tickets, newValue); }
/** * Copy the current immutable object by setting a value for the {@link CItemType#date() date} attribute. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for date * @return A modified copy of the {@code this} object */ public final CItem withDate(LocalDate value) { if (this.date == value) return this; LocalDate newValue = Objects.requireNonNull(value, "date"); return new CItem(this, newValue, this.summary, this.tickets, this.type); }