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 ImListCLASS_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 believe this class is thread-safe.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static @NotNull Stringname(@Nullable Class c)static @NotNull ImList<Class>registerClasses(@NotNull Class @NotNull ... cs)Use this to register runtime type signaturesstatic @NotNull Stringunion2Str(Object item, @NotNull ImList<Class> types)
-
-
-
Method Detail
-
registerClasses
@NotNull public static @NotNull ImList<Class> registerClasses(@NotNull @NotNull Class @NotNull ... cs)
Use this to register runtime type signatures- Parameters:
cs- an array of types- Returns:
- An immutable vector of those types. Given the same types, always returns the same vector.
-
-