From 02c5be5b72be71234cbf7a599f1fa7b070066817 Mon Sep 17 00:00:00 2001 From: Kyle Gunger Date: Fri, 17 Apr 2020 11:39:12 -0400 Subject: [Update] Version 0.9.2 + Change AcceptorNode and ProviderNode to IAcceptorNode and IProviderNode + Change function in IAcceptorNode to be Templated --- .../net/corechg/transit/network/system/Node.java | 45 ---------------------- .../net/corechg/transit/network/system/System.java | 17 -------- .../transit/network/system/swap/AcceptorNode.java | 39 ------------------- .../transit/network/system/swap/IAcceptorNode.java | 39 +++++++++++++++++++ .../transit/network/system/swap/IProviderNode.java | 29 ++++++++++++++ .../transit/network/system/swap/ProviderNode.java | 29 -------------- src/main/java/net/corechg/transit/type/Type.java | 4 +- .../net/corechg/transit/type/group/TypeGroup.java | 33 +++++++++++++++- src/main/resources/fabric.mod.json | 2 +- 9 files changed, 103 insertions(+), 134 deletions(-) delete mode 100644 src/main/java/net/corechg/transit/network/system/Node.java delete mode 100644 src/main/java/net/corechg/transit/network/system/System.java delete mode 100644 src/main/java/net/corechg/transit/network/system/swap/AcceptorNode.java create mode 100644 src/main/java/net/corechg/transit/network/system/swap/IAcceptorNode.java create mode 100644 src/main/java/net/corechg/transit/network/system/swap/IProviderNode.java delete mode 100644 src/main/java/net/corechg/transit/network/system/swap/ProviderNode.java (limited to 'src') diff --git a/src/main/java/net/corechg/transit/network/system/Node.java b/src/main/java/net/corechg/transit/network/system/Node.java deleted file mode 100644 index 87682ce..0000000 --- a/src/main/java/net/corechg/transit/network/system/Node.java +++ /dev/null @@ -1,45 +0,0 @@ -package net.corechg.transit.network.system; - -/** - * @author Kyle Gunger - * @apiNote A node inside or outside a system. Provides acceptors and providers to other nodes. - */ -public interface Node -{ - - /**Returns the groupIDs of groups the node interacts with - * - * @return String[] - */ - public String[] groupsProvided(); - - - /**Get the system managing the node or {@code null} if there isn't one - * - * @return System - */ - public System getSystem(); - - - /** Get the data of one of the TypeGroups the Node supports - * - * @param groupID - * @return - */ - public Object getData(String groupID); - - - /** Set the group data for the node - * - * @param dat - * @param groupID - */ - public void setData(Object dat, String groupID); - - - /** Get the nodes that this node is connected to - * - * @return Node[] - */ - public Node[] getConnections(); -} diff --git a/src/main/java/net/corechg/transit/network/system/System.java b/src/main/java/net/corechg/transit/network/system/System.java deleted file mode 100644 index dfe3e19..0000000 --- a/src/main/java/net/corechg/transit/network/system/System.java +++ /dev/null @@ -1,17 +0,0 @@ -package net.corechg.transit.network.system; - - -/**ISystem - a group of nodes optimized for performance - * - * A node can exist without a system, but a system can not exist without at least one root node. - * - * @param T The object type stored in the system. - */ -public interface System -{ - /**The nodes stored by the system - * - * @return INode[] - */ - public Node[] getNodes(); -} diff --git a/src/main/java/net/corechg/transit/network/system/swap/AcceptorNode.java b/src/main/java/net/corechg/transit/network/system/swap/AcceptorNode.java deleted file mode 100644 index 720b210..0000000 --- a/src/main/java/net/corechg/transit/network/system/swap/AcceptorNode.java +++ /dev/null @@ -1,39 +0,0 @@ -package net.corechg.transit.network.system.swap; - -import net.corechg.transit.network.packet.IStaticPacket; -import net.corechg.transit.network.system.INode; - -public interface AcceptorNode extends INode -{ - - /** Link another node as a provider - * - * @param requester The object to be a provider - * @param group - * @return - */ - public boolean linkProvider(INode requester, String group); - - - /** Unlink a provider from the acceptor - * - * @param toUnlink - * @return - */ - public boolean unlinkProvider(INode toUnlink); - - - /** - * @return Node[] - */ - public INode[] getProviders(); - - - /** Accept a packet from a provider - * - * @param packet - * @param group - * @return - */ - public boolean accept(IStaticPacket packet, String group); -} diff --git a/src/main/java/net/corechg/transit/network/system/swap/IAcceptorNode.java b/src/main/java/net/corechg/transit/network/system/swap/IAcceptorNode.java new file mode 100644 index 0000000..40cd430 --- /dev/null +++ b/src/main/java/net/corechg/transit/network/system/swap/IAcceptorNode.java @@ -0,0 +1,39 @@ +package net.corechg.transit.network.system.swap; + +import net.corechg.transit.network.packet.IStaticPacket; +import net.corechg.transit.network.system.INode; + +public interface IAcceptorNode extends INode +{ + + /** Link another node as a provider + * + * @param requester The object to be a provider + * @param group + * @return + */ + public boolean linkProvider(INode requester, String group); + + + /** Unlink a provider from the acceptor + * + * @param toUnlink + * @return + */ + public boolean unlinkProvider(INode toUnlink); + + + /** + * @return Node[] + */ + public INode[] getProviders(); + + + /** Accept a packet from a provider + * + * @param packet + * @param group + * @return + */ + public boolean accept(IStaticPacket packet, String group); +} diff --git a/src/main/java/net/corechg/transit/network/system/swap/IProviderNode.java b/src/main/java/net/corechg/transit/network/system/swap/IProviderNode.java new file mode 100644 index 0000000..84a8f62 --- /dev/null +++ b/src/main/java/net/corechg/transit/network/system/swap/IProviderNode.java @@ -0,0 +1,29 @@ +package net.corechg.transit.network.system.swap; + +import net.corechg.transit.network.system.INode; + +public interface IProviderNode extends INode{ + + /** Link another node as an acceptor + * + * @param requester The object requesting the Acceptor + * @param group + * @return boolean + */ + public boolean linkAcceptor(INode requester, String group); + + + /** Unlink a provider from the acceptor + * + * @param toUnlink + * @return + */ + public boolean unlinkAcceptor(INode toUnlink); + + + /** + * @return Node[] + */ + public INode[] getAcceptors(); + +} diff --git a/src/main/java/net/corechg/transit/network/system/swap/ProviderNode.java b/src/main/java/net/corechg/transit/network/system/swap/ProviderNode.java deleted file mode 100644 index 06b13f4..0000000 --- a/src/main/java/net/corechg/transit/network/system/swap/ProviderNode.java +++ /dev/null @@ -1,29 +0,0 @@ -package net.corechg.transit.network.system.swap; - -import net.corechg.transit.network.system.INode; - -public interface ProviderNode extends INode{ - - /** Link another node as an acceptor - * - * @param requester The object requesting the Acceptor - * @param group - * @return boolean - */ - public boolean linkAcceptor(INode requester, String group); - - - /** Unlink a provider from the acceptor - * - * @param toUnlink - * @return - */ - public boolean unlinkAcceptor(INode toUnlink); - - - /** - * @return Node[] - */ - public INode[] getAcceptors(); - -} diff --git a/src/main/java/net/corechg/transit/type/Type.java b/src/main/java/net/corechg/transit/type/Type.java index c5be2bb..2c4d6ac 100644 --- a/src/main/java/net/corechg/transit/type/Type.java +++ b/src/main/java/net/corechg/transit/type/Type.java @@ -19,6 +19,7 @@ public class Type } /** Return the packet's data formatted in the group's base type. + * If creating a new type, extend this class and override this function. * * @param packet The packet (of this type) * @param group The group asking for the conversion @@ -30,6 +31,7 @@ public class Type } /** Create a packet which has the current type from the data in the base type. + * If creating a new type, extend this class and override this function. * * @param base The base data * @param group The group that the data comes from @@ -40,7 +42,7 @@ public class Type return new StaticPacket(base, this); } - /** The type identifier. Must be overridden for any class implementing IType. + /** The type identifier. Gives the normal type identity of the type. * * @return String */ diff --git a/src/main/java/net/corechg/transit/type/group/TypeGroup.java b/src/main/java/net/corechg/transit/type/group/TypeGroup.java index adbd75f..e04df8c 100644 --- a/src/main/java/net/corechg/transit/type/group/TypeGroup.java +++ b/src/main/java/net/corechg/transit/type/group/TypeGroup.java @@ -103,7 +103,6 @@ public class TypeGroup */ public boolean removeType(String typeID) { - return removeType(getGroup(), typeID); } @@ -153,7 +152,8 @@ public class TypeGroup /**Get the type from the group * - * @param type + * @param groupID The ID of the group the type is originally from + * @param typeID The ID of the type * @return Type */ public Type getType(String groupID, String typeID) @@ -166,6 +166,11 @@ public class TypeGroup return null; } + /**Get the type from the group + * + * @param typeID The ID of the type + * @return Type + */ public Type getType(String typeID) { return getType(getGroup(), typeID); @@ -218,6 +223,23 @@ public class TypeGroup return null; } + + /**Convert a packet to a new type + * + * @param packet The packet to convert + * @param typeID The typeID of the Type to convert to + * @return Packet + */ + public IStaticPacket convertPacket(IStaticPacket packet, String typeID) + { + Type toType = getType(typeID); + if(toType != null) + { + return convertPacketRaw(packet, toType); + } + + return null; + } /** The group identifier. Given by the Base Group * @return String @@ -226,4 +248,11 @@ public class TypeGroup { return baseType.getGroup(); } + + /** The base group type + * @return Type + */ + public final Type getBase() { + return baseType; + } } diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index b7c73f7..70852d9 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -1,7 +1,7 @@ { "schemaVersion": 1, "id": "transit-api", - "version": "0.8.1", + "version": "0.9.2", "name": "Transit API", "description": "Move about!", -- cgit v1.2.3