mirror of
https://github.com/danieldemus/openhab-core.git
synced 2026-07-29 12:34:22 +02:00
model.script.StateAndCommandProvider: make methods static (#5401)
This commit is contained in:
-5
@@ -24,7 +24,6 @@ import org.openhab.core.model.script.jvmmodel.ScriptTypeComputer
|
||||
import org.openhab.core.model.script.scoping.ActionClassLoader
|
||||
import org.openhab.core.model.script.scoping.ScriptImplicitlyImportedTypes
|
||||
import org.openhab.core.model.script.scoping.ScriptImportSectionNamespaceScopeProvider
|
||||
import org.openhab.core.model.script.scoping.StateAndCommandProvider
|
||||
import org.eclipse.xtext.common.types.access.IJvmTypeProvider
|
||||
import org.eclipse.xtext.common.types.access.reflect.ReflectionTypeProviderFactory
|
||||
import org.eclipse.xtext.common.types.access.reflect.ReflectionTypeScopeProvider
|
||||
@@ -57,10 +56,6 @@ import org.eclipse.xtext.xbase.typesystem.computation.ITypeComputer
|
||||
return ScriptImplicitlyImportedTypes
|
||||
}
|
||||
|
||||
def Class<StateAndCommandProvider> bindStateAndCommandProvider() {
|
||||
return StateAndCommandProvider
|
||||
}
|
||||
|
||||
override Class<? extends IGenerator> bindIGenerator() {
|
||||
return NullGenerator
|
||||
}
|
||||
|
||||
+1
-5
@@ -65,9 +65,6 @@ class RulesJvmModelInferrer extends ScriptJvmModelInferrer {
|
||||
@Inject
|
||||
ThingRegistry thingRegistry
|
||||
|
||||
@Inject
|
||||
StateAndCommandProvider stateAndCommandProvider
|
||||
|
||||
/**
|
||||
* Is called for each instance of the first argument's type contained in a resource.
|
||||
*
|
||||
@@ -90,8 +87,7 @@ class RulesJvmModelInferrer extends ScriptJvmModelInferrer {
|
||||
|
||||
val Set<String> fieldNames = newHashSet()
|
||||
|
||||
val types = stateAndCommandProvider.allTypes
|
||||
types.forEach [ type |
|
||||
StateAndCommandProvider::allTypes.forEach [ type |
|
||||
val name = type.toString
|
||||
if (fieldNames.add(name)) {
|
||||
members += ruleModel.toField(name, typeRef(type.class)) [
|
||||
|
||||
+1
-4
@@ -51,9 +51,6 @@ class ScriptInterpreter extends XbaseInterpreter {
|
||||
@Inject
|
||||
ItemRegistry itemRegistry
|
||||
|
||||
@Inject
|
||||
StateAndCommandProvider stateAndCommandProvider
|
||||
|
||||
@Inject
|
||||
IBatchTypeResolver typeResolver;
|
||||
|
||||
@@ -100,7 +97,7 @@ class ScriptInterpreter extends XbaseInterpreter {
|
||||
}
|
||||
|
||||
def protected Type getStateOrCommand(String name) {
|
||||
for (Type type : stateAndCommandProvider.getAllTypes()) {
|
||||
for (Type type : StateAndCommandProvider::allTypes) {
|
||||
if (type.toString == name) {
|
||||
return type
|
||||
}
|
||||
|
||||
+1
-5
@@ -98,9 +98,6 @@ class ScriptJvmModelInferrer extends AbstractModelInferrer {
|
||||
@Inject
|
||||
ItemRegistry itemRegistry
|
||||
|
||||
@Inject
|
||||
StateAndCommandProvider stateAndCommandProvider
|
||||
|
||||
/**
|
||||
* Is called for each instance of the first argument's type contained in a resource.
|
||||
*
|
||||
@@ -116,8 +113,7 @@ class ScriptJvmModelInferrer extends AbstractModelInferrer {
|
||||
|
||||
val Set<String> fieldNames = newHashSet()
|
||||
|
||||
val types = stateAndCommandProvider.allTypes
|
||||
types.forEach [ type |
|
||||
StateAndCommandProvider::allTypes.forEach [ type |
|
||||
val name = type.toString
|
||||
if (fieldNames.add(name)) {
|
||||
members += script.toField(name, typeRef(type.class)) [
|
||||
|
||||
+3
-6
@@ -29,8 +29,6 @@ import org.openhab.core.types.State;
|
||||
import org.openhab.core.types.Type;
|
||||
import org.openhab.core.types.UnDefType;
|
||||
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
/**
|
||||
* This is a class which provides all available states and commands (obviously only the enum-based ones with a fixed
|
||||
* name).
|
||||
@@ -38,7 +36,6 @@ import com.google.inject.Singleton;
|
||||
*
|
||||
* @author Kai Kreuzer - Initial contribution
|
||||
*/
|
||||
@Singleton
|
||||
public class StateAndCommandProvider {
|
||||
|
||||
protected static final Set<Command> COMMANDS = new HashSet<>();
|
||||
@@ -79,15 +76,15 @@ public class StateAndCommandProvider {
|
||||
TYPES.addAll(STATES);
|
||||
}
|
||||
|
||||
public Iterable<Type> getAllTypes() {
|
||||
static public Iterable<Type> getAllTypes() {
|
||||
return TYPES;
|
||||
}
|
||||
|
||||
public Iterable<Command> getAllCommands() {
|
||||
static public Iterable<Command> getAllCommands() {
|
||||
return COMMANDS;
|
||||
}
|
||||
|
||||
public Iterable<State> getAllStates() {
|
||||
static public Iterable<State> getAllStates() {
|
||||
return STATES;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user