mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-14 19:56:19 +00:00
constant returnable helper method
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
package com.dfsek.terra.addons.terrascript.api.lang;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.api.ImplementationArguments;
|
||||
import com.dfsek.terra.addons.terrascript.api.Position;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface Returnable<T> extends Item<T> {
|
||||
ReturnType returnType();
|
||||
|
||||
@@ -16,4 +21,23 @@ public interface Returnable<T> extends Item<T> {
|
||||
return comparable;
|
||||
}
|
||||
}
|
||||
|
||||
static <T> Returnable<T> constant(T value, ReturnType type, Position position) {
|
||||
return new Returnable<T>() {
|
||||
@Override
|
||||
public ReturnType returnType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T apply(ImplementationArguments implementationArguments, Map<String, Variable<?>> variableMap) {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Position getPosition() {
|
||||
return position;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user