diff options
author | Jon Bratseth <bratseth@oath.com> | 2018-02-17 16:32:51 +0100 |
---|---|---|
committer | Jon Bratseth <bratseth@oath.com> | 2018-02-17 16:32:51 +0100 |
commit | d7e1e3b5b24b0f9f0e3dfcc6d1e37d442f1de4e8 (patch) | |
tree | 6520dc0340d605bba01bfbd7e3c9d3fd59bd4f5a /config-model/src/main/java/com | |
parent | 80f0982ad44485879cc98aeb6e7bde3bd6b3bbb3 (diff) |
Static type check reference parameters
Diffstat (limited to 'config-model/src/main/java/com')
-rw-r--r-- | config-model/src/main/java/com/yahoo/searchdefinition/MapEvaluationTypeContext.java | 15 |
1 files changed, 4 insertions, 11 deletions
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<Reference> { private final Map<Reference, TensorType> 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<String> binding = boundIdentifier(reference); if (binding.isPresent()) { try { |