blob: ff2e6318b372ea81432f58b3456845ed2e6dc238 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.tensor.evaluation;
import com.yahoo.tensor.TensorType;
/**
* Provides type information about a context (set of variable bindings).
*
* @author bratseth
*/
public interface TypeContext<NAMETYPE extends TypeContext.Name> {
/**
* Returns the type of the tensor with this name.
*
* @return returns the type of the tensor which will be returned by calling getTensor(name)
* or null if getTensor will return null.
*/
TensorType getType(NAMETYPE name);
/**
* Returns the type of the tensor with this name by converting from a string name.
*
* @return returns the type of the tensor which will be returned by calling getTensor(name)
* or null if getTensor will return null.
*/
TensorType getType(String name);
/** A name which is just a string. Names are value objects. */
class Name {
private final String name;
public Name(String name) {
this.name = name;
}
@Override
public String toString() { return name; }
@Override
public int hashCode() { return name.hashCode(); }
@Override
public boolean equals(Object other) {
if (other == this) return true;
if ( ! (other instanceof Name)) return false;
return ((Name)other).name.equals(this.name);
}
}
}
|