/** * Copy the current immutable object by setting a value for the {@link Value#getModifyIndex() modifyIndex} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for modifyIndex * @return A modified copy of the {@code this} object */ public final ImmutableValue withModifyIndex(long value) { if (this.modifyIndex == value) return this; return new ImmutableValue(this.createIndex, value, this.lockIndex, this.key, this.flags, this.value, this.session); }
/** * This instance is equal to all instances of {@code ImmutableValue} 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 ImmutableValue && equalTo((ImmutableValue) another); }
/** * Creates an immutable copy of a {@link Value} 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 Value instance */ public static ImmutableValue copyOf(Value instance) { if (instance instanceof ImmutableValue) { return (ImmutableValue) instance; } return ImmutableValue.builder() .from(instance) .build(); }
@JsonCreator static ImmutableValue fromJson(Json json) { ImmutableValue.Builder builder = ImmutableValue.builder(); if (json.createIndex != null) { builder.createIndex(json.createIndex);
/** * Copy the current immutable object by setting a value for the {@link Value#getFlags() flags} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for flags * @return A modified copy of the {@code this} object */ public final ImmutableValue withFlags(long value) { if (this.flags == value) return this; return new ImmutableValue(this.createIndex, this.modifyIndex, this.lockIndex, this.key, value, this.value, this.session); }
/** * Copy the current immutable object by setting a value for the {@link Value#getCreateIndex() createIndex} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for createIndex * @return A modified copy of the {@code this} object */ public final ImmutableValue withCreateIndex(long value) { if (this.createIndex == value) return this; return new ImmutableValue(value, this.modifyIndex, this.lockIndex, this.key, this.flags, this.value, this.session); }
/** * Copy the current immutable object by setting a value for the {@link Value#getLockIndex() lockIndex} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for lockIndex * @return A modified copy of the {@code this} object */ public final ImmutableValue withLockIndex(long value) { if (this.lockIndex == value) return this; return new ImmutableValue(this.createIndex, this.modifyIndex, value, this.key, this.flags, this.value, this.session); }
/** * Copy the current immutable object by setting a <i>present</i> value for the optional {@link Value#getSession() session} attribute. * @param value The value for session * @return A modified copy of {@code this} object */ public final ImmutableValue withSession(String value) { @Nullable String newValue = Preconditions.checkNotNull(value, "session"); if (Objects.equals(this.session, newValue)) return this; return new ImmutableValue(this.createIndex, this.modifyIndex, this.lockIndex, this.key, this.flags, this.value, newValue); }
/** * Copy the current immutable object by setting an optional value for the {@link Value#getValue() value} attribute. * An equality check is used on inner nullable value to prevent copying of the same value by returning {@code this}. * @param optional A value for value * @return A modified copy of {@code this} object */ public final ImmutableValue withValue(Optional<String> optional) { @Nullable String value = optional.orElse(null); if (Objects.equals(this.value, value)) return this; return new ImmutableValue(this.createIndex, this.modifyIndex, this.lockIndex, this.key, this.flags, value, this.session); }
/** * Copy the current immutable object by setting an optional value for the {@link Value#getSession() session} attribute. * An equality check is used on inner nullable value to prevent copying of the same value by returning {@code this}. * @param optional A value for session * @return A modified copy of {@code this} object */ public final ImmutableValue withSession(Optional<String> optional) { @Nullable String value = optional.orElse(null); if (Objects.equals(this.session, value)) return this; return new ImmutableValue(this.createIndex, this.modifyIndex, this.lockIndex, this.key, this.flags, this.value, value); }
/** * Copy the current immutable object by setting a value for the {@link Value#getKey() key} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for key * @return A modified copy of the {@code this} object */ public final ImmutableValue withKey(String value) { if (this.key.equals(value)) return this; return new ImmutableValue( this.createIndex, this.modifyIndex, this.lockIndex, Preconditions.checkNotNull(value, "key"), this.flags, this.value, this.session); }
/** * Copy the current immutable object by setting a <i>present</i> value for the optional {@link Value#getValue() value} attribute. * @param value The value for value * @return A modified copy of {@code this} object */ public final ImmutableValue withValue(String value) { @Nullable String newValue = Preconditions.checkNotNull(value, "value"); if (Objects.equals(this.value, newValue)) return this; return new ImmutableValue( this.createIndex, this.modifyIndex, this.lockIndex, this.key, this.flags, newValue, this.session); }
/** * Builds a new {@link ImmutableValue ImmutableValue}. * @return An immutable instance of Value * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableValue build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new ImmutableValue(createIndex, modifyIndex, lockIndex, key, flags, value, session); }