java.lang.Object
org.kink_lang.kink.ComponentRegistry
The component registry of the VM.
 
Components are any objects which are registered to the VM. A component is registered with its class. For a class, only one component can be registered. The second or later attempts of registration do not succeed.
- See Also:
 
- 
Method Summary
Modifier and TypeMethodDescription<T> TReturns a component registered with the class.<T> TgetOrRegister(Class<T> klass, Function<Vm, T> makeComponent) Returns a component registered with the class; if it is not registered yet, makes one viamakeComponent, then registers and returns it.<T> voidRegisters the component with the class, only if no component is registered with the class. 
- 
Method Details
- 
get
Returns a component registered with the class.- Type Parameters:
 T- the type of the class of the component.- Parameters:
 klass- the class of the component.- Returns:
 - the component.
 - Throws:
 IllegalStateException- if it is not registered yet.
 - 
register
Registers the component with the class, only if no component is registered with the class.- Type Parameters:
 T- the type of the class of the component.- Parameters:
 klass- the class of the component.component- the component.
 - 
getOrRegister
Returns a component registered with the class; if it is not registered yet, makes one viamakeComponent, then registers and returns it.Example:
class X { X(Vm vm) {} } X x = vm.component.getOrRegister(X.class, X::new);- Type Parameters:
 T- the type of the class of the component.- Parameters:
 klass- the class of the component.makeComponent- a function to make a component.- Returns:
 - the component.
 
 
 -