Package org.organicdesign.fp.type
Class RuntimeTypes
- java.lang.Object
-
- org.organicdesign.fp.type.RuntimeTypes
-
public final class RuntimeTypes extends Object
Stores the classes from the compile-time generic type parameters in a vector in the *same order* as the generics in the type signature of that class. Store them here usingregisterClasses(Class[])
to avoid duplication. For example:
Now you if you use CLASS_STRING_INTEGER, you are never creating a new vector. For a full example of how to use these RuntimeTypes, seeprivate static final ImList
CLASS_STRING_INTEGER = RuntimeTypes.registerClasses(vec(String.class, Integer.class)); OneOf2
. This is an experiment in runtime types for Java. Constructive criticism is appreciated! If you write a programming language, your compiler can manage these vectors so that humans don't have to ever think about them, except to query them when they want to. I wanted to do this with arrays, but I didn't trust that they wouldn't be mutated, so I used ImList's.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
name(Class c)
static ImList<Class>
registerClasses(@NotNull Class... cs)
Use this to prevent duplicate runtime types.static String
union2Str(Object item, ImList<Class> types)
-