summaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorKyle Gunger <corechg@gmail.com>2020-07-23 19:31:09 -0400
committerKyle Gunger <corechg@gmail.com>2020-07-23 19:31:09 -0400
commit9edd770911a9dfd5b350d579e9092a62873e1d4a (patch)
treeea231adc14d60c94047929a656f70b406c198113 /src/main/java
parent0afbfce255bd7625396ad729b33bcecff09bd5b2 (diff)
Proper type checking
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/net/corechg/transit/type/group/GroupRegistry.java15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/main/java/net/corechg/transit/type/group/GroupRegistry.java b/src/main/java/net/corechg/transit/type/group/GroupRegistry.java
index 3929973..0b04913 100644
--- a/src/main/java/net/corechg/transit/type/group/GroupRegistry.java
+++ b/src/main/java/net/corechg/transit/type/group/GroupRegistry.java
@@ -30,20 +30,27 @@ public class GroupRegistry {
return true;
}
- public static final TypeGroup<?> groupByID(String groupID)
+ @SuppressWarnings("unchecked")
+ public static final <T> TypeGroup<T> groupByID(String groupID)
{
for(TypeGroup<?> g : GROUPS)
{
- if(g.getGroup().equals(groupID)) return g;
+ if(g.getGroup().equals(groupID)){
+ try{
+ return (TypeGroup<T>) g;
+ }catch(ClassCastException e) {
+ return null;
+ }
+ }
}
return null;
}
- public static final Type<?> typeByIdentity(String groupID, String typeID)
+ public static final <T> Type<T> typeByIdentity(String groupID, String typeID)
{
- return groupByID(groupID).getType(typeID);
+ return GroupRegistry.<T>groupByID(groupID).getType(typeID);
}
}