summaryrefslogtreecommitdiff
path: root/src/main/java/net
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/net')
-rw-r--r--src/main/java/net/transit/impl/IAcceptor.java6
-rw-r--r--src/main/java/net/transit/impl/IConsumer.java4
-rw-r--r--src/main/java/net/transit/impl/IGenerator.java4
-rw-r--r--src/main/java/net/transit/impl/IProvider.java8
-rw-r--r--src/main/java/net/transit/packet/ArrayPacket.java37
-rw-r--r--src/main/java/net/transit/packet/IPacket.java6
-rw-r--r--src/main/java/net/transit/packet/StaticPacket.java16
-rw-r--r--src/main/java/net/transit/type/BaseType.java14
-rw-r--r--src/main/java/net/transit/type/IBaseType.java7
-rw-r--r--src/main/java/net/transit/type/IType.java10
-rw-r--r--src/main/java/net/transit/type/Type.java18
-rw-r--r--src/main/java/net/transit/type/typebase/MetaBase.java6
-rw-r--r--src/main/java/net/transit/type/typebase/NumberBase.java6
-rw-r--r--src/main/java/net/transit/type/typebase/StringBase.java6
-rw-r--r--src/main/java/net/transit/type/typegroup/TypeGroup.java20
-rw-r--r--src/main/java/net/transit/type/typegroup/TypeRegister.java8
16 files changed, 127 insertions, 49 deletions
diff --git a/src/main/java/net/transit/impl/IAcceptor.java b/src/main/java/net/transit/impl/IAcceptor.java
index 9433ea3..7fe06aa 100644
--- a/src/main/java/net/transit/impl/IAcceptor.java
+++ b/src/main/java/net/transit/impl/IAcceptor.java
@@ -1,13 +1,13 @@
package net.transit.impl;
-import net.transit.type.IType;
+import net.transit.packet.IPacket;
import net.minecraft.util.math.Direction;
-public interface IAcceptor<T extends IType<?, ?>>
+public interface IAcceptor<T>
{
// Direction given if acceptor is a block
public boolean canAccept(Direction d);
// Accept (or not) a provided T (should trigger ITransferEvent)
- public boolean accept(T provided);
+ public boolean accept(IPacket<T> provided);
} \ No newline at end of file
diff --git a/src/main/java/net/transit/impl/IConsumer.java b/src/main/java/net/transit/impl/IConsumer.java
index d709430..7b3b070 100644
--- a/src/main/java/net/transit/impl/IConsumer.java
+++ b/src/main/java/net/transit/impl/IConsumer.java
@@ -1,8 +1,6 @@
package net.transit.impl;
-import net.transit.type.IType;
-
-public interface IConsumer<T extends IType<?, ?>> extends IAcceptor<T>
+public interface IConsumer<T> extends IAcceptor<T>
{
public boolean canConsume();
diff --git a/src/main/java/net/transit/impl/IGenerator.java b/src/main/java/net/transit/impl/IGenerator.java
index 009f268..f69de2f 100644
--- a/src/main/java/net/transit/impl/IGenerator.java
+++ b/src/main/java/net/transit/impl/IGenerator.java
@@ -1,8 +1,6 @@
package net.transit.impl;
-import net.transit.type.IType;
-
-public interface IGenerator<T extends IType<?, ?>> extends IProvider<T>
+public interface IGenerator<T> extends IProvider<T>
{
public boolean canGenerate();
diff --git a/src/main/java/net/transit/impl/IProvider.java b/src/main/java/net/transit/impl/IProvider.java
index b613436..94e903f 100644
--- a/src/main/java/net/transit/impl/IProvider.java
+++ b/src/main/java/net/transit/impl/IProvider.java
@@ -1,17 +1,17 @@
package net.transit.impl;
-import net.transit.type.IType;
+import net.transit.packet.IPacket;
import net.minecraft.util.math.Direction;
-public interface IProvider<T extends IType<?, ?>>
+public interface IProvider<T>
{
// Direction given if provider is a block
public boolean canProvide(Direction d);
// Provide the next T (should trigger ITransferEvent)
- public T provide();
+ public IPacket<T> provide();
// Retain the rejected T if the acceptor did not accept it (should trigger ITransferEvent)
- public void accept(T rejected);
+ public void retain(IPacket<T> rejected);
} \ No newline at end of file
diff --git a/src/main/java/net/transit/packet/ArrayPacket.java b/src/main/java/net/transit/packet/ArrayPacket.java
new file mode 100644
index 0000000..09ef5f1
--- /dev/null
+++ b/src/main/java/net/transit/packet/ArrayPacket.java
@@ -0,0 +1,37 @@
+package net.transit.packet;
+
+import java.util.ArrayList;
+
+public class ArrayPacket<D> implements IPacket<D>
+{
+ private ArrayList<D> arrayData;
+
+ public ArrayPacket(D startValue)
+ {
+ arrayData = new ArrayList<D>(0);
+ arrayData.add(startValue);
+ }
+
+ public D getData()
+ {
+ if(arrayData.size() > 0) return arrayData.get(0);
+ return null;
+ }
+
+ public void addData(D data)
+ {
+ arrayData.add(data);
+ }
+
+ public D popAndShift()
+ {
+ D temp = null;
+
+ if(arrayData.size() > 0)
+ {
+ temp = arrayData.remove(0);
+ }
+
+ return temp;
+ }
+} \ No newline at end of file
diff --git a/src/main/java/net/transit/packet/IPacket.java b/src/main/java/net/transit/packet/IPacket.java
new file mode 100644
index 0000000..2b1753b
--- /dev/null
+++ b/src/main/java/net/transit/packet/IPacket.java
@@ -0,0 +1,6 @@
+package net.transit.packet;
+
+public interface IPacket<D>
+{
+ public D getData();
+} \ No newline at end of file
diff --git a/src/main/java/net/transit/packet/StaticPacket.java b/src/main/java/net/transit/packet/StaticPacket.java
new file mode 100644
index 0000000..fb11dd7
--- /dev/null
+++ b/src/main/java/net/transit/packet/StaticPacket.java
@@ -0,0 +1,16 @@
+package net.transit.packet;
+
+public class StaticPacket<D> implements IPacket<D>
+{
+ private D data;
+
+ public StaticPacket(D dat)
+ {
+ data = dat;
+ }
+
+ public D getData()
+ {
+ return data;
+ }
+} \ No newline at end of file
diff --git a/src/main/java/net/transit/type/BaseType.java b/src/main/java/net/transit/type/BaseType.java
new file mode 100644
index 0000000..1202f95
--- /dev/null
+++ b/src/main/java/net/transit/type/BaseType.java
@@ -0,0 +1,14 @@
+package net.transit.type;
+
+public abstract class BaseType<T>
+{
+
+ public static final String TYPE_NAME = "BASE";
+
+ private T data;
+
+ public T getData()
+ {
+ return data;
+ }
+} \ No newline at end of file
diff --git a/src/main/java/net/transit/type/IBaseType.java b/src/main/java/net/transit/type/IBaseType.java
deleted file mode 100644
index 99ec178..0000000
--- a/src/main/java/net/transit/type/IBaseType.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package net.transit.type;
-
-public interface IBaseType<T>
-{
-
- public T getData();
-} \ No newline at end of file
diff --git a/src/main/java/net/transit/type/IType.java b/src/main/java/net/transit/type/IType.java
deleted file mode 100644
index ff401f1..0000000
--- a/src/main/java/net/transit/type/IType.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package net.transit.type;
-
-public interface IType<T, B> extends IBaseType<B>
-{
- public String getTypeName();
-
- public IBaseType<B> convertToBase();
-
- public IType<T, B> convertFromBase(IBaseType<B> base);
-} \ No newline at end of file
diff --git a/src/main/java/net/transit/type/Type.java b/src/main/java/net/transit/type/Type.java
new file mode 100644
index 0000000..0c6fc91
--- /dev/null
+++ b/src/main/java/net/transit/type/Type.java
@@ -0,0 +1,18 @@
+package net.transit.type;
+
+import net.transit.packet.IPacket;
+
+public abstract class Type<T, B> extends BaseType<T>
+{
+ public static final String TYPE_NAME = "TYPE";
+
+ public B convertToBase()
+ {
+ return null;
+ }
+
+ public IPacket<T> convertFromBase(B base)
+ {
+ return null;
+ }
+} \ No newline at end of file
diff --git a/src/main/java/net/transit/type/typebase/MetaBase.java b/src/main/java/net/transit/type/typebase/MetaBase.java
index fdf69a8..e1e6f5c 100644
--- a/src/main/java/net/transit/type/typebase/MetaBase.java
+++ b/src/main/java/net/transit/type/typebase/MetaBase.java
@@ -1,12 +1,14 @@
package net.transit.type.typebase;
-import net.transit.type.IBaseType;
+import net.transit.type.BaseType;
-public class MetaBase<T extends IBaseType<?>> implements IBaseType<T>
+public class MetaBase<T extends BaseType<?>> extends BaseType<T>
{
private T data;
private String metaData;
+ public static final String TYPE_NAME = "BASE_META";
+
public MetaBase(T dat, String meta)
{
data = dat;
diff --git a/src/main/java/net/transit/type/typebase/NumberBase.java b/src/main/java/net/transit/type/typebase/NumberBase.java
index 2a3c013..a8d5ca3 100644
--- a/src/main/java/net/transit/type/typebase/NumberBase.java
+++ b/src/main/java/net/transit/type/typebase/NumberBase.java
@@ -1,11 +1,13 @@
package net.transit.type.typebase;
-import net.transit.type.IBaseType;
+import net.transit.type.BaseType;
-public class NumberBase implements IBaseType<Number>
+public class NumberBase extends BaseType<Number>
{
private Number data;
+ public static final String TYPE_NAME = "BASE_NUMBER";
+
public NumberBase(Number dat)
{
data = dat;
diff --git a/src/main/java/net/transit/type/typebase/StringBase.java b/src/main/java/net/transit/type/typebase/StringBase.java
index c1e32fe..8138b8d 100644
--- a/src/main/java/net/transit/type/typebase/StringBase.java
+++ b/src/main/java/net/transit/type/typebase/StringBase.java
@@ -1,11 +1,13 @@
package net.transit.type.typebase;
-import net.transit.type.IBaseType;
+import net.transit.type.BaseType;
-public class StringBase implements IBaseType<String>
+public class StringBase extends BaseType<String>
{
private String data;
+ public static final String TYPE_NAME = "BASE_STRING";
+
public StringBase(String dat)
{
data = dat;
diff --git a/src/main/java/net/transit/type/typegroup/TypeGroup.java b/src/main/java/net/transit/type/typegroup/TypeGroup.java
index 4524ae0..4349df6 100644
--- a/src/main/java/net/transit/type/typegroup/TypeGroup.java
+++ b/src/main/java/net/transit/type/typegroup/TypeGroup.java
@@ -2,43 +2,43 @@ package net.transit.type.typegroup;
import java.util.ArrayList;
-import net.transit.type.IType;
-import net.transit.type.IBaseType;
+import net.transit.type.Type;
+import net.transit.type.BaseType;
public class TypeGroup<B>
{
- private IBaseType<B> baseType;
+ private BaseType<B> baseType;
private String groupName;
- private ArrayList<IType<?, B>> types;
+ private ArrayList<Type<?, B>> types;
/**Create a new TypeGroup
*
* @param base The base type of the group.
* @param name The identifier of the group. Should be in all caps.
*/
- public TypeGroup(IBaseType<B> base, String name)
+ public TypeGroup(BaseType<B> base, String name)
{
baseType = base;
- types = new ArrayList<IType<?, B>>(0);
+ types = new ArrayList<Type<?, B>>(0);
groupName = name;
}
// Return the base type
- public IBaseType<B> getBaseType()
+ public BaseType<B> getBaseType()
{
return baseType;
}
// Returns if the type is supported by the group
- public boolean hasType(IType t)
+ public boolean hasType(Type<?, ?> t)
{
- for(IType gtype : types)
+ for(Type<?, B> gtype : types)
{
- if(t.getTypeName() == gtype.getTypeName()) return true;
+ if(t.TYPE_NAME == gtype.TYPE_NAME) return true;
}
return false;
diff --git a/src/main/java/net/transit/type/typegroup/TypeRegister.java b/src/main/java/net/transit/type/typegroup/TypeRegister.java
index 8de81a6..d226cbe 100644
--- a/src/main/java/net/transit/type/typegroup/TypeRegister.java
+++ b/src/main/java/net/transit/type/typegroup/TypeRegister.java
@@ -2,7 +2,7 @@ package net.transit.type.typegroup;
import java.util.ArrayList;
-import net.transit.type.IType;
+import net.transit.type.Type;
public final class TypeRegister
{
@@ -11,10 +11,12 @@ public final class TypeRegister
// Hold all the groups
private static ArrayList<TypeGroup<?>> groups = new ArrayList<TypeGroup<?>>(0);
+ private static ArrayList<Class> caster = new ArrayList<Class>(0);
+
// Add a group
public static void addTypeGroup(TypeGroup<?> g)
{
- if(getTypeGroup(g.getGroupName()) == null) return;
+ if(getTypeGroup(g.getGroupName()) != null) return;
groups.add(g);
}
@@ -30,7 +32,7 @@ public final class TypeRegister
return null;
}
- public static String groupOf(IType<?, ?> t)
+ public static String groupOf(Type<?, ?> t)
{
for(TypeGroup<?> g : groups)
{