From 957365ab91a285109e2978333828d09d256dfcee Mon Sep 17 00:00:00 2001 From: Luck Date: Fri, 20 Apr 2018 14:00:50 +0100 Subject: [PATCH] refactor inheritance graphs slightly --- .../luckperms/common/event/AbstractEvent.java | 2 +- .../me/lucko/luckperms/common/graph/Graph.java | 12 ++++++++++++ .../common/inheritance/InheritanceGraph.java | 14 -------------- .../inheritance/SubjectInheritanceGraph.java | 14 -------------- 4 files changed, 13 insertions(+), 29 deletions(-) diff --git a/common/src/main/java/me/lucko/luckperms/common/event/AbstractEvent.java b/common/src/main/java/me/lucko/luckperms/common/event/AbstractEvent.java index 28f1cab2..1d91b397 100644 --- a/common/src/main/java/me/lucko/luckperms/common/event/AbstractEvent.java +++ b/common/src/main/java/me/lucko/luckperms/common/event/AbstractEvent.java @@ -40,7 +40,7 @@ public abstract class AbstractEvent implements LuckPermsEvent { return this.api; } - public void setApi(LuckPermsApi api) { + void setApi(LuckPermsApi api) { this.api = api; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/graph/Graph.java b/common/src/main/java/me/lucko/luckperms/common/graph/Graph.java index b3477d43..64ce386c 100644 --- a/common/src/main/java/me/lucko/luckperms/common/graph/Graph.java +++ b/common/src/main/java/me/lucko/luckperms/common/graph/Graph.java @@ -41,4 +41,16 @@ public interface Graph { */ Iterable successors(N node); + /** + * Returns an iterable which will traverse this graph using the specified algorithm starting + * at the given node. + * + * @param algorithm the algorithm to use when traversing + * @param startNode the start node in the inheritance graph + * @return an iterable + */ + default Iterable traverse(TraversalAlgorithm algorithm, N startNode) { + return GraphTraversers.traverseUsing(algorithm, this, startNode); + } + } \ No newline at end of file diff --git a/common/src/main/java/me/lucko/luckperms/common/inheritance/InheritanceGraph.java b/common/src/main/java/me/lucko/luckperms/common/inheritance/InheritanceGraph.java index 3b3bbdf9..81efdbe8 100644 --- a/common/src/main/java/me/lucko/luckperms/common/inheritance/InheritanceGraph.java +++ b/common/src/main/java/me/lucko/luckperms/common/inheritance/InheritanceGraph.java @@ -26,8 +26,6 @@ package me.lucko.luckperms.common.inheritance; import me.lucko.luckperms.common.graph.Graph; -import me.lucko.luckperms.common.graph.GraphTraversers; -import me.lucko.luckperms.common.graph.TraversalAlgorithm; import me.lucko.luckperms.common.model.PermissionHolder; /** @@ -35,16 +33,4 @@ import me.lucko.luckperms.common.model.PermissionHolder; */ public interface InheritanceGraph extends Graph { - /** - * Returns an iterable which will traverse this inheritance graph using the - * specified algorithm starting at the given node. - * - * @param algorithm the algorithm to use when traversing - * @param startNode the start node in the inheritance graph - * @return an iterable - */ - default Iterable traverse(TraversalAlgorithm algorithm, PermissionHolder startNode) { - return GraphTraversers.traverseUsing(algorithm, this, startNode); - } - } diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/service/inheritance/SubjectInheritanceGraph.java b/sponge/src/main/java/me/lucko/luckperms/sponge/service/inheritance/SubjectInheritanceGraph.java index 038ed4a9..c328ef2c 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/service/inheritance/SubjectInheritanceGraph.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/service/inheritance/SubjectInheritanceGraph.java @@ -26,8 +26,6 @@ package me.lucko.luckperms.sponge.service.inheritance; import me.lucko.luckperms.common.graph.Graph; -import me.lucko.luckperms.common.graph.GraphTraversers; -import me.lucko.luckperms.common.graph.TraversalAlgorithm; import me.lucko.luckperms.sponge.service.calculated.CalculatedSubject; /** @@ -35,16 +33,4 @@ import me.lucko.luckperms.sponge.service.calculated.CalculatedSubject; */ public interface SubjectInheritanceGraph extends Graph { - /** - * Returns an iterable which will traverse this inheritance graph using the - * specified algorithm starting at the given node. - * - * @param algorithm the algorithm to use when traversing - * @param startNode the start node in the inheritance graph - * @return an iterable - */ - default Iterable traverse(TraversalAlgorithm algorithm, CalculatedSubject startNode) { - return GraphTraversers.traverseUsing(algorithm, this, startNode); - } - }