/** * Creates a new {@link DataTransactionResult} that ends in failure. The * provided {@link ImmutableValue}s are considered "rejected" and were not * successfully added. * * @param values The values that were rejected * @return The new data transaction result */ public static DataTransactionResult failResult(final Iterable<ImmutableValue<?>> values) { return builder().reject(values).result(Type.FAILURE).build(); }
/** * Creates a new {@link DataTransactionResult} that ends in failure. The * provided {@link ImmutableValue} is considered "incompatible" and was not * successfully added. * * @param value The value that was incompatible or errored * @return The new data transaction result */ public static DataTransactionResult errorResult(final ImmutableValue<?> value) { return builder().result(Type.ERROR).reject(value).build(); }
/** * Creates a new {@link DataTransactionResult} that ends in failure. The * provided {@link ImmutableValue} is considered "rejected" and was not * successfully added. * * @param value The value that was rejected * @return The new data transaction result */ public static DataTransactionResult failResult(final ImmutableValue<?> value) { return builder().reject(value).result(Type.FAILURE).build(); }
/** * Creates a {@link DataTransactionResult} with the provided * {@link ImmutableValue}s being successfully removed. The result type is * still {@link Type#SUCCESS}. If a {@link Value} is necessary, use * {@link Value#asImmutable()} to use this method. A {@link DataTransactionResult} * is always immutable once created, and any {@link BaseValue}s should be provided * as {@link ImmutableValue}s or transformed into {@link ImmutableValue}s. * * @param removed The successfully removed values * @return The new data transaction result */ public static DataTransactionResult successRemove(Collection<ImmutableValue<?>> removed) { return builder().replace(removed).result(Type.SUCCESS).build(); }
/** * Creates a new {@link DataTransactionResult} with the provided * {@link ImmutableValue} being the successful addition. The result type is * still {@link Type#SUCCESS}. If a {@link Value} is * necessary, use {@link Value#asImmutable()} to use this method. A * {@link DataTransactionResult} is always immutable once created, and any * {@link BaseValue}s should be provided as {@link ImmutableValue}s or * transformed into {@link ImmutableValue}s. * * @param value The successfully added immutable value * @return The new data transaction result */ public static DataTransactionResult successResult(final ImmutableValue<?> value) { return builder().success(value).result(Type.SUCCESS).build(); }
/** * Creates a {@link DataTransactionResult} with the provided * {@link ImmutableValue} being successfully removed. The result type is * still {@link Type#SUCCESS}. If a {@link Value} is necessary, use * {@link Value#asImmutable()} to use this method. A * {@link DataTransactionResult} is always immutable once created, and a * {@link BaseValue} should be provided as an {@link ImmutableValue} or * transformed into an {@link ImmutableValue}. * * @param removed The successfully removed value * @return The new data transaction result */ public static DataTransactionResult successRemove(ImmutableValue<?> removed) { return builder().replace(removed).result(Type.SUCCESS).build(); }
/** * Offers all provided {@link ValueContainer}s to this * {@link CompositeValueStore} much like {@link #offer(ValueContainer)} * except all in a single batch. The end result of the values successfully * offered, rejected, and replaced are stored in the returned * {@link DataTransactionResult}. Any merge conflicts are resolved through * the {@link MergeFunction}. * * @param valueContainers The values to set * @param function The function to resolve the values * @return The transaction result */ default DataTransactionResult offer(Iterable<H> valueContainers, MergeFunction function) { final DataTransactionResult.Builder builder = DataTransactionResult.builder(); for (H valueContainer : valueContainers) { builder.absorbResult(offer(valueContainer, function)); } return builder.build(); }
/** * Offers the provided {@link DataManipulator}s to the block at the given * position. * * <p>If any data is rejected or existing data is replaced, the * {@link DataTransactionResult} will retain the rejected, replaced, and * successfully offered data.</p> * * @param x The X position * @param y The Y position * @param z The Z position * @param manipulators The values to offer * @return The transaction result */ default DataTransactionResult offer(int x, int y, int z, Iterable<DataManipulator<?, ?>> manipulators) { final DataTransactionResult.Builder builder = DataTransactionResult.builder(); for (DataManipulator<?, ?> manipulator : manipulators) { builder.absorbResult(offer(x, y, z, manipulator, MergeFunction.IGNORE_ALL)); } return builder.build(); }
/** * Creates a new {@link DataTransactionResult} with the provided * {@link ImmutableValue}s being the successful additions and * the provided {@link ImmutableValue}s that were replaced. The result type * is still {@link Type#SUCCESS}. If a {@link Value} * is necessary, use {@link Value#asImmutable()} to use this method. A * {@link DataTransactionResult} is always immutable once created, and any * {@link BaseValue}s should be provided as {@link ImmutableValue}s or * transformed into {@link ImmutableValue}s. * * @param successful The successfully added immutable values * @param replaced The successfully replaced immutable values * @return The new data transaction result */ public static DataTransactionResult successReplaceResult(Collection<ImmutableValue<?>> successful, Collection<ImmutableValue<?>> replaced) { return builder().success(successful).replace(replaced).result(Type.SUCCESS).build(); }
/** * Creates a new {@link DataTransactionResult} with the provided * {@link ImmutableValue} being the successful addition. The result type is * still {@link Type#SUCCESS}. If a {@link Value} is * necessary, use {@link Value#asImmutable()} to use this method. A * {@link DataTransactionResult} is always immutable once created, and any * {@link BaseValue}s should be provided as {@link ImmutableValue}s or * transformed into {@link ImmutableValue}s. * * @param successful The successfully added immutable value * @param replaced The replaced value * @return The new data transaction result */ public static DataTransactionResult successReplaceResult(final ImmutableValue<?> successful, final ImmutableValue<?> replaced) { return builder().result(Type.SUCCESS).success(successful).replace(replaced).build(); }
/** * Offers the provided {@link DataManipulator}s to the block at the given * position. * * <p>If any data is rejected or existing data is replaced, the * {@link DataTransactionResult} will retain the rejected, replaced, and * successfully offered data.</p> * * @param coordinates The position of the block * @param manipulators The values to offer * @return The transaction result */ default DataTransactionResult offer(Vector3i coordinates, Iterable<DataManipulator<?, ?>> manipulators) { final DataTransactionResult.Builder builder = DataTransactionResult.builder(); for (DataManipulator<?, ?> manipulator : manipulators) { builder.absorbResult(offer(coordinates.getX(), coordinates.getY(), coordinates.getZ(), manipulator, MergeFunction.IGNORE_ALL)); } return builder.build(); }
/** * Offers the provided {@link DataManipulator}s to the block at the given * position. If there's any overlaps of data, the provided * {@link MergeFunction} is used to delegate the merges. It is possible to * recycle {@link MergeFunction}s provided that the {@link MergeFunction} is * aware of being usable in multiple environments. * * <p>If any data is rejected or existing data is replaced, the * {@link DataTransactionResult} will retain the rejected, replaced, and * successfully offered data.</p> * * @param blockPosition The block position * @param values The values to offer * @param function The merge function to resolve conflicts * @return The transaction result */ default DataTransactionResult offer(Vector3i blockPosition, Iterable<DataManipulator<?, ?>> values, MergeFunction function) { final DataTransactionResult.Builder builder = DataTransactionResult.builder(); for (DataManipulator<?, ?> manipulator : values) { builder.absorbResult(offer(blockPosition.getX(), blockPosition.getY(), blockPosition.getZ(), manipulator, function)); } return builder.build(); }
/** * Creates a new {@link DataTransactionResult} that ends in failure. The * provided {@link ImmutableValue}s are considered "rejected" and were not * successfully added. * * @param values The values that were rejected * @return The new data transaction result */ public static DataTransactionResult failResult(final Iterable<ImmutableValue<?>> values) { return builder().reject(values).result(Type.FAILURE).build(); }
/** * Creates a new {@link DataTransactionResult} that ends in failure. The * provided {@link ImmutableValue} is considered "incompatible" and was not * successfully added. * * @param value The value that was incompatible or errored * @return The new data transaction result */ public static DataTransactionResult errorResult(final ImmutableValue<?> value) { return builder().result(Type.ERROR).reject(value).build(); }
/** * Creates a new {@link DataTransactionResult} that ends in failure. The * provided {@link ImmutableValue} is considered "rejected" and was not * successfully added. * * @param value The value that was rejected * @return The new data transaction result */ public static DataTransactionResult failResult(final ImmutableValue<?> value) { return builder().reject(value).result(Type.FAILURE).build(); }
/** * Creates a new {@link DataTransactionResult} with the provided * {@link ImmutableValue} being the successful addition. The result type is * still {@link Type#SUCCESS}. If a {@link Value} is * necessary, use {@link Value#asImmutable()} to use this method. A * {@link DataTransactionResult} is always immutable once created, and any * {@link BaseValue}s should be provided as {@link ImmutableValue}s or * transformed into {@link ImmutableValue}s. * * @param value The successfully added immutable value * @return The new data transaction result */ public static DataTransactionResult successResult(final ImmutableValue<?> value) { return builder().success(value).result(Type.SUCCESS).build(); }
/** * Creates a {@link DataTransactionResult} with the provided * {@link ImmutableValue}s being successfully removed. The result type is * still {@link Type#SUCCESS}. If a {@link Value} is necessary, use * {@link Value#asImmutable()} to use this method. A {@link DataTransactionResult} * is always immutable once created, and any {@link BaseValue}s should be provided * as {@link ImmutableValue}s or transformed into {@link ImmutableValue}s. * * @param removed The successfully removed values * @return The new data transaction result */ public static DataTransactionResult successRemove(Collection<ImmutableValue<?>> removed) { return builder().replace(removed).result(Type.SUCCESS).build(); }
/** * Creates a {@link DataTransactionResult} with the provided * {@link ImmutableValue} being successfully removed. The result type is * still {@link Type#SUCCESS}. If a {@link Value} is necessary, use * {@link Value#asImmutable()} to use this method. A * {@link DataTransactionResult} is always immutable once created, and a * {@link BaseValue} should be provided as an {@link ImmutableValue} or * transformed into an {@link ImmutableValue}. * * @param removed The successfully removed value * @return The new data transaction result */ public static DataTransactionResult successRemove(ImmutableValue<?> removed) { return builder().replace(removed).result(Type.SUCCESS).build(); }
/** * Creates a new {@link DataTransactionResult} with the provided * {@link ImmutableValue} being the successful addition. The result type is * still {@link Type#SUCCESS}. If a {@link Value} is * necessary, use {@link Value#asImmutable()} to use this method. A * {@link DataTransactionResult} is always immutable once created, and any * {@link BaseValue}s should be provided as {@link ImmutableValue}s or * transformed into {@link ImmutableValue}s. * * @param successful The successfully added immutable value * @param replaced The replaced value * @return The new data transaction result */ public static DataTransactionResult successReplaceResult(final ImmutableValue<?> successful, final ImmutableValue<?> replaced) { return builder().result(Type.SUCCESS).success(successful).replace(replaced).build(); }