Added a valueBuilder convenience method to DataExtension

This commit is contained in:
Risto Lahtela 2021-04-07 20:11:59 +03:00
parent 113d46669b
commit 9466dc3e9d
2 changed files with 21 additions and 9 deletions

View File

@ -18,6 +18,7 @@ package com.djrapitops.plan.extension;
import com.djrapitops.plan.extension.annotation.PluginInfo;
import com.djrapitops.plan.extension.builder.ExtensionDataBuilder;
import com.djrapitops.plan.extension.builder.ValueBuilder;
/**
* Interface to implement data extensions with.
@ -107,6 +108,17 @@ public interface DataExtension {
return ExtensionService.getInstance().newExtensionDataBuilder(this);
}
/**
* Obtain a new {@link ValueBuilder} to use with {@link ExtensionDataBuilder}.
* <p>
* Requires Capability DATA_EXTENSION_BUILDER_API
*
* @return new builder.
*/
default ValueBuilder valueBuilder(String text) {
return newExtensionDataBuilder().valueBuilder(text);
}
/**
* Get the name of the plugin from PluginInfo annotation.
* <p>

View File

@ -205,57 +205,57 @@ public interface ValueBuilder {
/**
* Lambda version for conditional return or throwing {@link com.djrapitops.plan.extension.NotReadyException}.
*
* @see ValueBuilder#buildBoolean(boolean).
* <p>
* {@link ValueBuilder#buildBoolean(boolean)}
*/
DataValue<Boolean> buildBoolean(Supplier<Boolean> value);
/**
* Lambda version for conditional return or throwing {@link com.djrapitops.plan.extension.NotReadyException}.
*
* @see ValueBuilder#buildBooleanProvidingCondition(boolean, String).
* {@link ValueBuilder#buildBooleanProvidingCondition(boolean, String)}
*/
DataValue<Boolean> buildBooleanProvidingCondition(Supplier<Boolean> value, String providedCondition);
/**
* Lambda version for conditional return or throwing {@link com.djrapitops.plan.extension.NotReadyException}.
*
* @see ValueBuilder#buildString(String)
* {@link ValueBuilder#buildString(String)}
*/
DataValue<String> buildString(Supplier<String> value);
/**
* Lambda version for conditional return or throwing {@link com.djrapitops.plan.extension.NotReadyException}.
*
* @see ValueBuilder#buildNumber(long)
* {@link ValueBuilder#buildNumber(long)}
*/
DataValue<Long> buildNumber(Supplier<Long> value);
/**
* Lambda version for conditional return or throwing {@link com.djrapitops.plan.extension.NotReadyException}.
*
* @see ValueBuilder#buildDouble(double)
* {@link ValueBuilder#buildDouble(double)}
*/
DataValue<Double> buildDouble(Supplier<Double> value);
/**
* Lambda version for conditional return or throwing {@link com.djrapitops.plan.extension.NotReadyException}.
*
* @see ValueBuilder#buildPercentage(double)
* {@link ValueBuilder#buildPercentage(double)}
*/
DataValue<Double> buildPercentage(Supplier<Double> percentage);
/**
* Lambda version for conditional return or throwing {@link com.djrapitops.plan.extension.NotReadyException}.
*
* @see ValueBuilder#buildGroup(String[])
* {@link ValueBuilder#buildGroup(String[])}
*/
DataValue<String[]> buildGroup(Supplier<String[]> groups);
/**
* Lambda version for conditional return or throwing {@link com.djrapitops.plan.extension.NotReadyException}.
*
* @see ValueBuilder#buildTable(Table, Color)
* {@link ValueBuilder#buildTable(Table, Color)}
*/
DataValue<Table> buildTable(Supplier<Table> table, Color tableColor);