From d08cbf6b8705df234077c49608de3c2f7ff0e3fa Mon Sep 17 00:00:00 2001 From: Kyle Gunger Date: Thu, 21 Nov 2019 18:35:14 -0500 Subject: [Update] Codebase updated to 0.2.8 ~ Rewrote files and documentation for cohesion ~ Removed I from the start of interface names --- .../net/transit/network/packet/ArrayPacket.java | 11 +++++++++-- .../java/net/transit/network/packet/IPacket.java | 23 ---------------------- .../net/transit/network/packet/MetaPacket.java | 2 +- .../java/net/transit/network/packet/Packet.java | 23 ++++++++++++++++++++++ .../net/transit/network/packet/StaticPacket.java | 2 +- 5 files changed, 34 insertions(+), 27 deletions(-) delete mode 100644 src/main/java/net/transit/network/packet/IPacket.java create mode 100644 src/main/java/net/transit/network/packet/Packet.java (limited to 'src/main/java/net/transit/network/packet') diff --git a/src/main/java/net/transit/network/packet/ArrayPacket.java b/src/main/java/net/transit/network/packet/ArrayPacket.java index 9cbd300..fbea811 100644 --- a/src/main/java/net/transit/network/packet/ArrayPacket.java +++ b/src/main/java/net/transit/network/packet/ArrayPacket.java @@ -4,7 +4,7 @@ import java.util.ArrayList; import net.transit.type.Type; -public class ArrayPacket implements IPacket +public class ArrayPacket implements Packet { private ArrayList arrayData; private Type type; @@ -13,8 +13,10 @@ public class ArrayPacket implements IPacket { arrayData = new ArrayList(0); arrayData.add(startValue); + type = t; } - + + @Override public D getData() { if(arrayData.size() > 0) return arrayData.get(0); @@ -25,6 +27,11 @@ public class ArrayPacket implements IPacket { arrayData.add(data); } + + public int dataStored() + { + return arrayData.size(); + } public D popAndShift() { diff --git a/src/main/java/net/transit/network/packet/IPacket.java b/src/main/java/net/transit/network/packet/IPacket.java deleted file mode 100644 index deafdf8..0000000 --- a/src/main/java/net/transit/network/packet/IPacket.java +++ /dev/null @@ -1,23 +0,0 @@ -package net.transit.network.packet; - -import net.transit.type.Type; - -/** - * @author Kyle Gunger - * - * @param The data type (Object) that the packet transfers. - */ -public interface IPacket -{ - /**Get the packet's data - * - * @return The packet's data - */ - public D getData(); - - /**Get the packet's type - * - * @return IType<> The type of the packet - */ - public Type getType(); -} \ No newline at end of file diff --git a/src/main/java/net/transit/network/packet/MetaPacket.java b/src/main/java/net/transit/network/packet/MetaPacket.java index e4cffdf..0240519 100644 --- a/src/main/java/net/transit/network/packet/MetaPacket.java +++ b/src/main/java/net/transit/network/packet/MetaPacket.java @@ -2,7 +2,7 @@ package net.transit.network.packet; import net.transit.type.Type; -public class MetaPacket implements IPacket +public class MetaPacket implements Packet { private D data; diff --git a/src/main/java/net/transit/network/packet/Packet.java b/src/main/java/net/transit/network/packet/Packet.java new file mode 100644 index 0000000..0b7c832 --- /dev/null +++ b/src/main/java/net/transit/network/packet/Packet.java @@ -0,0 +1,23 @@ +package net.transit.network.packet; + +import net.transit.type.Type; + +/** + * @author Kyle Gunger + * + * @param The data type (Object) that the packet transfers. + */ +public interface Packet +{ + /**Get the packet's data + * + * @return The packet's data + */ + public D getData(); + + /**Get the packet's type + * + * @return IType<> The type of the packet + */ + public Type getType(); +} \ No newline at end of file diff --git a/src/main/java/net/transit/network/packet/StaticPacket.java b/src/main/java/net/transit/network/packet/StaticPacket.java index 8399041..b14e442 100644 --- a/src/main/java/net/transit/network/packet/StaticPacket.java +++ b/src/main/java/net/transit/network/packet/StaticPacket.java @@ -2,7 +2,7 @@ package net.transit.network.packet; import net.transit.type.Type; -public class StaticPacket implements IPacket +public class StaticPacket implements Packet { private D data; private Type type; -- cgit v1.2.3