Use thee default set of flags by default in QueryOptions.Builder, etc

This commit is contained in:
Luck committed 2019-12-13 11:28:46 +00:00
1 parent d8ac199858
commit 06f7900318
6 files changed
+29 -15

No files matched your search

@@ -25,10 +25,6 @@
package net.luckperms.api.query;
import net.luckperms.api.context.ImmutableContextSet;
import java.util.EnumSet;
/**
* Some default {@link QueryOptions} instances.
*/
@@ -38,7 +34,6 @@ final class DefaultQueryOptions {
}
private static boolean setup = false;
private static final EnumSet<Flag> DEFAULT_FLAGS = EnumSet.allOf(Flag.class);
private static QueryOptions contextual;
private static QueryOptions nonContextual;
@@ -47,8 +42,8 @@ final class DefaultQueryOptions {
return;
}
setup = true;
contextual = QueryOptions.contextual(ImmutableContextSet.empty(), DEFAULT_FLAGS);
nonContextual = QueryOptions.nonContextual(DEFAULT_FLAGS);
contextual = QueryOptions.builder(QueryMode.CONTEXTUAL).build();
nonContextual = QueryOptions.builder(QueryMode.NON_CONTEXTUAL).build();
}
static QueryOptions contextual() {
@@ -27,6 +27,9 @@ package net.luckperms.api.query;
/**
* The flags which can be set for a query.
*
* <p>By default (in places like new instances of {@link QueryOptions.Builder} and
* {@link QueryOptions#defaultContextualOptions()}), all {@link Flag}s are set to true.</p>
*/
public enum Flag {
@@ -71,7 +71,7 @@ public interface QueryOptions {
* @return the query options
*/
static @NonNull QueryOptions contextual(@NonNull ContextSet context) {
return defaultContextualOptions().toBuilder().context(context).build();
return builder(QueryMode.CONTEXTUAL).context(context).build();
}
/**
@@ -208,6 +208,8 @@ public interface QueryOptions {
/**
* Sets the value of the given flag.
*
* <p>By default, all {@link Flag}s are set to true.</p>
*
* @param flag the flag
* @param value the value to set
* @return this builder
@@ -220,6 +222,8 @@ public interface QueryOptions {
* <p>Note that this is a set operation, not append. Existing flags will
* be overridden.</p>
*
* <p>By default, all {@link Flag}s are set to true.</p>
*
* @param flags the flags
* @return this builder
*/