public final class RuntimeTypes extends Object
registerClasses(Class[])
to avoid duplication. For example:
private static final ImList CLASS_STRING_INTEGER =
RuntimeTypes.registerClasses(vec(String.class, Integer.class));
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, see 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.Modifier and Type | Method and Description |
---|---|
static String |
name(Class c) |
static ImList<Class> |
registerClasses(Class... cs)
Use this to prevent duplicate runtime types.
|
static String |
union2Str(Object item,
ImList<Class> types) |
Copyright © 2018. All rights reserved.