Some tidying up

This commit is contained in:
Luck 2020-12-09 10:46:22 +00:00
parent 5fbb80f16a
commit 39a5ccf9a9
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
5 changed files with 14 additions and 10 deletions

View File

@ -27,10 +27,12 @@ package me.lucko.luckperms.common.node.types;
import me.lucko.luckperms.common.node.AbstractNode;
import me.lucko.luckperms.common.node.AbstractNodeBuilder;
import net.luckperms.api.context.ImmutableContextSet;
import net.luckperms.api.model.group.Group;
import net.luckperms.api.node.metadata.NodeMetadataKey;
import net.luckperms.api.node.types.InheritanceNode;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;

View File

@ -28,9 +28,11 @@ package me.lucko.luckperms.common.node.types;
import me.lucko.luckperms.common.node.AbstractNode;
import me.lucko.luckperms.common.node.AbstractNodeBuilder;
import me.lucko.luckperms.common.node.factory.Delimiters;
import net.luckperms.api.context.ImmutableContextSet;
import net.luckperms.api.node.metadata.NodeMetadataKey;
import net.luckperms.api.node.types.MetaNode;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;

View File

@ -33,9 +33,9 @@ import java.util.Set;
final class FlagUtils {
private FlagUtils() {}
private static final EnumSet<Flag> DEFAULT_FLAGS_SET = EnumSet.allOf(Flag.class);
private static final int DEFAULT_FLAGS_SIZE = DEFAULT_FLAGS_SET.size();
static final byte DEFAULT_FLAGS = toByte0(DEFAULT_FLAGS_SET);
private static final EnumSet<Flag> ALL_FLAGS_SET = EnumSet.allOf(Flag.class);
private static final int ALL_FLAGS_SIZE = ALL_FLAGS_SET.size();
static final byte ALL_FLAGS = toByte0(ALL_FLAGS_SET);
/* bitwise utility methods */
@ -45,8 +45,8 @@ final class FlagUtils {
static byte toByte(Set<Flag> settings) {
// fast path for the default set of flags.
if (settings.size() == DEFAULT_FLAGS_SIZE) {
return DEFAULT_FLAGS;
if (settings.size() == ALL_FLAGS_SIZE) {
return ALL_FLAGS;
}
return toByte0(settings);
}

View File

@ -54,7 +54,7 @@ public class QueryOptionsBuilderImpl implements QueryOptions.Builder {
public QueryOptionsBuilderImpl(QueryMode mode) {
this.mode = mode;
this.context = mode == QueryMode.CONTEXTUAL ? ImmutableContextSetImpl.EMPTY : null;
this.flags = FlagUtils.DEFAULT_FLAGS;
this.flags = FlagUtils.ALL_FLAGS;
this.flagsSet = null;
this.options = null;
this.copyOptions = false;
@ -150,13 +150,13 @@ public class QueryOptionsBuilderImpl implements QueryOptions.Builder {
if (this.options == null) {
if (this.mode == QueryMode.NON_CONTEXTUAL) {
if (FlagUtils.DEFAULT_FLAGS == flags) {
if (FlagUtils.ALL_FLAGS == flags) {
// mode same, contexts null, flags same, options null
// so therefore, equal to default - return that instead!
return QueryOptionsImpl.DEFAULT_NON_CONTEXTUAL;
}
} else if (this.mode == QueryMode.CONTEXTUAL) {
if (FlagUtils.DEFAULT_FLAGS == flags && this.context.isEmpty()) {
if (FlagUtils.ALL_FLAGS == flags && this.context.isEmpty()) {
// mode same, contexts empty, flags same, options null
// so therefore, equal to default - return that instead!
return QueryOptionsImpl.DEFAULT_CONTEXTUAL;

View File

@ -47,8 +47,8 @@ import java.util.Optional;
import java.util.Set;
public class QueryOptionsImpl implements QueryOptions {
public static final QueryOptions DEFAULT_CONTEXTUAL = new QueryOptionsImpl(QueryMode.CONTEXTUAL, ImmutableContextSetImpl.EMPTY, FlagUtils.DEFAULT_FLAGS, null);
public static final QueryOptions DEFAULT_NON_CONTEXTUAL = new QueryOptionsImpl(QueryMode.NON_CONTEXTUAL, null, FlagUtils.DEFAULT_FLAGS, null);
public static final QueryOptions DEFAULT_CONTEXTUAL = new QueryOptionsImpl(QueryMode.CONTEXTUAL, ImmutableContextSetImpl.EMPTY, FlagUtils.ALL_FLAGS, null);
public static final QueryOptions DEFAULT_NON_CONTEXTUAL = new QueryOptionsImpl(QueryMode.NON_CONTEXTUAL, null, FlagUtils.ALL_FLAGS, null);
// state
private final QueryMode mode;