-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
InstantiationSet.java
68 lines (52 loc) · 1.83 KB
/
InstantiationSet.java
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package com.github.javaparser.symbolsolver.resolution.typeinference;
import com.github.javaparser.resolution.types.ResolvedType;
import java.util.LinkedList;
import java.util.List;
/**
* @author Federico Tomassetti
*/
public class InstantiationSet {
private List<Instantiation> instantiations;
public boolean allInferenceVariablesAreResolved(BoundSet boundSet) {
throw new UnsupportedOperationException();
}
public static InstantiationSet empty() {
return EMPTY;
}
private static final InstantiationSet EMPTY = new InstantiationSet();
private InstantiationSet() {
instantiations = new LinkedList<>();
}
public InstantiationSet withInstantiation(Instantiation instantiation) {
InstantiationSet newInstance = new InstantiationSet();
newInstance.instantiations.addAll(this.instantiations);
newInstance.instantiations.add(instantiation);
return newInstance;
}
public boolean isEmpty() {
return instantiations.isEmpty();
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
InstantiationSet that = (InstantiationSet) o;
return instantiations.equals(that.instantiations);
}
@Override
public int hashCode() {
return instantiations.hashCode();
}
@Override
public String toString() {
return "InstantiationSet{" +
"instantiations=" + instantiations +
'}';
}
public ResolvedType apply(ResolvedType type) {
for (Instantiation instantiation : instantiations) {
type = type.replaceTypeVariables(instantiation.getInferenceVariable().getTypeParameterDeclaration(), instantiation.getProperType());
}
return type;
}
}