@Override protected boolean apply(Property<?, ?> operand1, Property<?, ?> operand2) { return operand2.getOperator() != Operator.DELEGATE && operand2.getOperator().compare(operand1, operand2); } },
/** * 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 DataContainer} with the provided * {@link org.spongepowered.api.data.DataView.SafetyMode}. * * @param safety The safety mode to use * @see org.spongepowered.api.data.DataView.SafetyMode * @return A new data container with the provided safety mode */ static DataContainer createNew(SafetyMode safety) { return new MemoryDataContainer(safety); }
@Override public DataContainer toContainer() { DataContainer container = DataContainer.createNew(); container.set(DataQuery.of("myInt"), this.testInt); container.set(DataQuery.of("myDouble"), this.testDouble); container.set(DataQuery.of("myString"), this.testString); container.set(DataQuery.of("myStringList"), Arrays.asList(this.testList)); return container; }
/** * 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(); }
/** * Gets whether this {@link DataTransactionResult} was successful or not. * * @return True if this result was successful */ public boolean isSuccessful() { return getType() == Type.SUCCESS; }
@Override public String toString() { return asString('.'); }
/** * Constructs a query using the given parts. * * @param parts The parts * @return The newly constructed {@link DataQuery} */ public static DataQuery of(String... parts) { if (parts.length == 0) { return DataQuery.EMPTY; } return new DataQuery(parts); }
/** * Gets a new {@link Builder} to build a new * {@link DataTransactionResult}. * * @return The new builder, for chaining */ public static Builder builder() { return new Builder(); }
@Override public DataContainer remove(DataQuery path) { return (DataContainer) super.remove(path); }
@Override public DataContainer set(DataQuery path, Object value) { return (DataContainer) super.set(path, value); }
/** * 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 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 DataContainer} with a default * {@link org.spongepowered.api.data.DataView.SafetyMode} of * {@link org.spongepowered.api.data.DataView.SafetyMode#ALL_DATA_CLONED}. * * @return A new data container */ static DataContainer createNew() { // TODO - Move to implementation - unit tests are difficult... return new MemoryDataContainer(); }
/** * 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} 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}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(); }