Deprecate some unused methods in ImmutableNode, refactor #shouldApplyWithContext

This commit is contained in:
Luck 2017-11-02 18:22:42 +00:00
parent 357717886e
commit 0f10bb0bc9
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B

View File

@ -308,11 +308,13 @@ public final class ImmutableNode implements Node {
} }
@Override @Override
@Deprecated
public boolean shouldApply(boolean includeGlobal, boolean includeGlobalWorld, String server, String world, ContextSet context, boolean applyRegex) { public boolean shouldApply(boolean includeGlobal, boolean includeGlobalWorld, String server, String world, ContextSet context, boolean applyRegex) {
return shouldApplyOnServer(server, includeGlobal, applyRegex) && shouldApplyOnWorld(world, includeGlobalWorld, applyRegex) && shouldApplyWithContext(context, false); return shouldApplyOnServer(server, includeGlobal, applyRegex) && shouldApplyOnWorld(world, includeGlobalWorld, applyRegex) && shouldApplyWithContext(context, false);
} }
@Override @Override
@Deprecated
public boolean shouldApplyOnServer(String server, boolean includeGlobal, boolean applyRegex) { public boolean shouldApplyOnServer(String server, boolean includeGlobal, boolean applyRegex) {
if (server == null || server.equals("") || server.equalsIgnoreCase("global")) { if (server == null || server.equals("") || server.equalsIgnoreCase("global")) {
return !isServerSpecific(); return !isServerSpecific();
@ -322,6 +324,7 @@ public final class ImmutableNode implements Node {
} }
@Override @Override
@Deprecated
public boolean shouldApplyOnWorld(String world, boolean includeGlobal, boolean applyRegex) { public boolean shouldApplyOnWorld(String world, boolean includeGlobal, boolean applyRegex) {
if (world == null || world.equals("") || world.equalsIgnoreCase("null")) { if (world == null || world.equals("") || world.equalsIgnoreCase("null")) {
return !isWorldSpecific(); return !isWorldSpecific();
@ -331,40 +334,22 @@ public final class ImmutableNode implements Node {
} }
@Override @Override
@Deprecated
public boolean shouldApplyWithContext(ContextSet context, boolean worldAndServer) { public boolean shouldApplyWithContext(ContextSet context, boolean worldAndServer) {
if (contexts.isEmpty() && !isServerSpecific() && !isWorldSpecific()) {
return true;
}
if (worldAndServer) { if (worldAndServer) {
if (isWorldSpecific()) { return getFullContexts().isSatisfiedBy(context, false);
if (context == null) return false; } else {
if (!context.hasIgnoreCase("world", world)) return false; return getContexts().isSatisfiedBy(context, false);
}
if (isServerSpecific()) {
if (context == null) return false;
if (!context.hasIgnoreCase("server", server)) return false;
}
} }
if (!contexts.isEmpty()) {
if (context == null) return false;
for (Map.Entry<String, String> c : contexts.toSet()) {
if (!context.hasIgnoreCase(c.getKey(), c.getValue())) return false;
}
}
return true;
} }
@Override @Override
public boolean shouldApplyWithContext(ContextSet context) { public boolean shouldApplyWithContext(ContextSet context) {
return shouldApplyWithContext(context, true); return getFullContexts().isSatisfiedBy(context, false);
} }
@Override @Override
@Deprecated
public boolean shouldApplyOnAnyServers(List<String> servers, boolean includeGlobal) { public boolean shouldApplyOnAnyServers(List<String> servers, boolean includeGlobal) {
for (String s : servers) { for (String s : servers) {
if (shouldApplyOnServer(s, includeGlobal, false)) { if (shouldApplyOnServer(s, includeGlobal, false)) {
@ -376,6 +361,7 @@ public final class ImmutableNode implements Node {
} }
@Override @Override
@Deprecated
public boolean shouldApplyOnAnyWorlds(List<String> worlds, boolean includeGlobal) { public boolean shouldApplyOnAnyWorlds(List<String> worlds, boolean includeGlobal) {
for (String s : worlds) { for (String s : worlds) {
if (shouldApplyOnWorld(s, includeGlobal, false)) { if (shouldApplyOnWorld(s, includeGlobal, false)) {