From d7e1e3b5b24b0f9f0e3dfcc6d1e37d442f1de4e8 Mon Sep 17 00:00:00 2001 From: Jon Bratseth Date: Sat, 17 Feb 2018 16:32:51 +0100 Subject: Static type check reference parameters --- .../yahoo/searchdefinition/MapEvaluationTypeContext.java | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to 'config-model/src/main/java/com/yahoo') diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/MapEvaluationTypeContext.java b/config-model/src/main/java/com/yahoo/searchdefinition/MapEvaluationTypeContext.java index f31dba74e9e..0b312d40815 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/MapEvaluationTypeContext.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/MapEvaluationTypeContext.java @@ -28,7 +28,7 @@ import java.util.Optional; * * @author bratseth */ -public class MapEvaluationTypeContext extends FunctionReferenceContext implements TypeContext { +public class MapEvaluationTypeContext extends FunctionReferenceContext implements TypeContext { private final Map featureTypes = new HashMap<>(); @@ -43,19 +43,12 @@ public class MapEvaluationTypeContext extends FunctionReferenceContext implement this.featureTypes.putAll(featureTypes); } - public void setType(Name name, TensorType type) { - // TODO: Use a type parameter if we do this both here and in getType ... - if ( ! (name instanceof Reference)) - throw new IllegalArgumentException("Not expecting unstructured names here"); - featureTypes.put((Reference)name, type); + public void setType(Reference reference, TensorType type) { + featureTypes.put(reference, type); } @Override - public TensorType getType(Name name) { - if ( ! (name instanceof Reference)) - throw new IllegalArgumentException("Not expecting unstructured names here"); - Reference reference = (Reference)name; - + public TensorType getType(Reference reference) { Optional binding = boundIdentifier(reference); if (binding.isPresent()) { try { -- cgit v1.2.3