From 0d147b3a184fc311bd3dae6bf1c974722753b3bf Mon Sep 17 00:00:00 2001 From: Kyle Gunger Date: Sat, 18 Nov 2023 14:30:50 -0500 Subject: Change namespace again --- .../transit/network/packet/DynamicPacket.java | 43 ++++++++++++++++++++++ .../transit/network/packet/IDynamicPacket.java | 11 ++++++ .../transit/network/packet/IStaticPacket.java | 23 ++++++++++++ .../transit/network/packet/StaticPacket.java | 36 ++++++++++++++++++ 4 files changed, 113 insertions(+) create mode 100644 src/main/java/net/cshift/transit/network/packet/DynamicPacket.java create mode 100644 src/main/java/net/cshift/transit/network/packet/IDynamicPacket.java create mode 100644 src/main/java/net/cshift/transit/network/packet/IStaticPacket.java create mode 100644 src/main/java/net/cshift/transit/network/packet/StaticPacket.java (limited to 'src/main/java/net/cshift/transit/network/packet') diff --git a/src/main/java/net/cshift/transit/network/packet/DynamicPacket.java b/src/main/java/net/cshift/transit/network/packet/DynamicPacket.java new file mode 100644 index 0000000..beeea97 --- /dev/null +++ b/src/main/java/net/cshift/transit/network/packet/DynamicPacket.java @@ -0,0 +1,43 @@ +package net.cshift.transit.network.packet; + +import net.cshift.transit.type.Type; + +/** + * Simple packet which stores a value which can change. + * + * @param The type parameter of the Type being transported + * @author Kyle Gunger + * + */ +public class DynamicPacket implements IDynamicPacket { + private Object data; + private Type type; + + /** Constructor. Stores the given data and uses the given type. + * + * @param dat The packet's data + * @param t The packet's type + */ + public DynamicPacket(Object dat, Type t) + { + data = dat; + type = t; + } + + @Override + public Object getData() + { + return data; + } + + @Override + public void setData(Object dat) + { + data = dat; + } + + @Override + public Type getType() { + return type; + } +} diff --git a/src/main/java/net/cshift/transit/network/packet/IDynamicPacket.java b/src/main/java/net/cshift/transit/network/packet/IDynamicPacket.java new file mode 100644 index 0000000..fca43e5 --- /dev/null +++ b/src/main/java/net/cshift/transit/network/packet/IDynamicPacket.java @@ -0,0 +1,11 @@ +package net.cshift.transit.network.packet; + +/** Interface describing a packet where the data can change as it's transferred. + * + * @param The type parameter of the Type being transported + * @author Kyle Gunger + */ +public interface IDynamicPacket extends IStaticPacket{ + /** Set the packet's data. */ + public void setData(Object dat); +} diff --git a/src/main/java/net/cshift/transit/network/packet/IStaticPacket.java b/src/main/java/net/cshift/transit/network/packet/IStaticPacket.java new file mode 100644 index 0000000..506a166 --- /dev/null +++ b/src/main/java/net/cshift/transit/network/packet/IStaticPacket.java @@ -0,0 +1,23 @@ +package net.cshift.transit.network.packet; + +import net.cshift.transit.type.*; + +/** Interface describing an unchanging packet. + * + * @param The type parameter of the Type being transported + * @author Kyle Gunger + */ +public interface IStaticPacket +{ + /**Get the packet's data. + * + * @return The packet's data + */ + public Object getData(); + + /**Get the packet's type. + * + * @return IType The type of the packet + */ + public Type getType(); +} diff --git a/src/main/java/net/cshift/transit/network/packet/StaticPacket.java b/src/main/java/net/cshift/transit/network/packet/StaticPacket.java new file mode 100644 index 0000000..3daefb0 --- /dev/null +++ b/src/main/java/net/cshift/transit/network/packet/StaticPacket.java @@ -0,0 +1,36 @@ +package net.cshift.transit.network.packet; + +import net.cshift.transit.type.*; + +/** Simple packet which stores an unchanging value. + * @author Kyle Gunger + * + * @param The data type (Object) that the packet transfers. + */ +public class StaticPacket implements IStaticPacket +{ + private Object data; + private Type type; + + /** Constructor. Stores the given data and uses the given type. + * + * @param dat The packet's data + * @param t The packet's type + */ + public StaticPacket(Object dat, Type t) + { + data = dat; + type = t; + } + + @Override + public Object getData() + { + return data; + } + + @Override + public Type getType() { + return type; + } +} -- cgit v1.2.3