Class TypeHolder<T extends Unifiable>
java.lang.Object
org.jfuncmachine.util.unification.TypeHolder<T>
- Type Parameters:
T- The type of types that the holder can hold
A type holder for unification
A TypeHolder holds a type for unification. It can hold a concrete type, which means
that it is not expected to change any more, or it can be empty, and when it is unified
with a TypeHolder that contains a concrete type, it is given to hold that type, and any
other empty TypeHolders it was previously unified with also are given that concrete type.
-
Field Summary
FieldsModifier and TypeFieldDescriptionThe type held by this holder, null if there isn't one yetSet<TypeHolder<T>> The TypeHolders that this holder has been linked with -
Constructor Summary
ConstructorsConstructorDescriptionCreate a new TypeHolderTypeHolder(T concreteType) Create a new TypeHolder already filled with a type -
Method Summary
Modifier and TypeMethodDescriptionbooleanisFull()Tests whether this TypeHolder already has a typevoidlink(TypeHolder<T> other) Link this TypeHolder to another TypeHolder, and link them both together with all the other TypeHolders they were each linked withvoidSet the type for this TypeHolder.voidunify(TypeHolder<T> other) Try to unify this TypeHolder with another.
-
Field Details
-
concreteType
The type held by this holder, null if there isn't one yet -
linked
The TypeHolders that this holder has been linked with
-
-
Constructor Details
-
TypeHolder
public TypeHolder()Create a new TypeHolder -
TypeHolder
Create a new TypeHolder already filled with a type- Parameters:
concreteType- The type to fill the holder with
-
-
Method Details
-
isFull
public boolean isFull()Tests whether this TypeHolder already has a type- Returns:
- True if this holder has a type
-
setType
Set the type for this TypeHolder. This will cause any empty holders linked to this type to be populated as well.- Parameters:
concreteType- The type the holder should contain
-
link
Link this TypeHolder to another TypeHolder, and link them both together with all the other TypeHolders they were each linked with- Parameters:
other- The other TypeHolder to link with
-
unify
Try to unify this TypeHolder with another.- If this TypeHolder is empty and the other is full, this TypeHolder and the other TypeHolders it is linked to are populated with the value in other.
- If this TypeHolder is full and the other is empty, the other TypeHolder and the TypeHolders it is linked to are all populated with the type in this TypeHolder.
- If both TypeHolders are empty, they are linked together, along with any TypeHolders they are already linked to.
- If both TypeHolders are full, their types are unified to ensure that they match
- Parameters:
other- The TypeHolder to unify with- Throws:
UnificationException- If there is an error unifying the types
-