/** * Builds a new {@link ImmutableTransactionOptions ImmutableTransactionOptions}. * @return An immutable instance of TransactionOptions * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableTransactionOptions build() { return new ImmutableTransactionOptions(this); } }
/** * This instance is equal to all instances of {@code ImmutableTransactionOptions} 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 ImmutableTransactionOptions && equalTo((ImmutableTransactionOptions) another); }
/** * Creates an immutable copy of a {@link TransactionOptions} 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 TransactionOptions instance */ public static ImmutableTransactionOptions copyOf(TransactionOptions instance) { if (instance instanceof ImmutableTransactionOptions) { return (ImmutableTransactionOptions) instance; } return ImmutableTransactionOptions.builder() .from(instance) .build(); }
/** * Performs a Consul transaction. * * PUT /v1/tx * * @param operations A list of KV operations. * @return A {@link ConsulResponse} containing results and potential errors. */ public ConsulResponse<TxResponse> performTransaction(Operation... operations) { ImmutableTransactionOptions immutableTransactionOptions = ImmutableTransactionOptions.builder().consistencyMode(ConsistencyMode.DEFAULT).build(); return performTransaction(immutableTransactionOptions, operations); }
/** * Copy the current immutable object by setting a value for the {@link TransactionOptions#getConsistencyMode() consistencyMode} 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 consistencyMode * @return A modified copy of the {@code this} object */ public final ImmutableTransactionOptions withConsistencyMode(ConsistencyMode value) { if (this.consistencyMode == value) return this; return new ImmutableTransactionOptions(this.datacenter, Preconditions.checkNotNull(value, "consistencyMode")); }
/** * Copy the current immutable object by setting a <i>present</i> value for the optional {@link TransactionOptions#getDatacenter() datacenter} attribute. * @param value The value for datacenter * @return A modified copy of {@code this} object */ public final ImmutableTransactionOptions withDatacenter(String value) { @Nullable String newValue = Preconditions.checkNotNull(value, "datacenter"); if (Objects.equals(this.datacenter, newValue)) return this; return new ImmutableTransactionOptions(newValue, this.consistencyMode); }
/** * Copy the current immutable object by setting an optional value for the {@link TransactionOptions#getDatacenter() datacenter} 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 datacenter * @return A modified copy of {@code this} object */ public final ImmutableTransactionOptions withDatacenter(Optional<String> optional) { @Nullable String value = optional.orElse(null); if (Objects.equals(this.datacenter, value)) return this; return new ImmutableTransactionOptions(value, this.consistencyMode); }