Class BoundSet
- java.lang.Object
-
- com.github.javaparser.symbolsolver.resolution.typeinference.BoundSet
-
public class BoundSet extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static interface
BoundSet.Processor<B1 extends Bound,B2 extends Bound,R>
private class
BoundSet.VariableDependency
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<Bound>
bounds
private static BoundSet
EMPTY
private static java.lang.String
JAVA_LANG_RUNTIME_EXCEPTION
-
Constructor Summary
Constructors Constructor Description BoundSet()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private <T> java.util.Set<T>
allButOne(java.util.Set<T> elements, T element)
private java.util.Set<InferenceVariable>
allInferenceVariables()
private java.util.Set<java.util.Set<InferenceVariable>>
allPossibleSetsWithProperty(java.util.Set<InferenceVariable> allElements, java.util.List<BoundSet.VariableDependency> dependencies)
private java.util.Set<java.util.Set<InferenceVariable>>
allSetsWithProperty(java.util.Set<InferenceVariable> allElements, java.util.List<BoundSet.VariableDependency> dependencies)
private boolean
appearInLeftPartOfCapture(InferenceVariable inferenceVariable)
private boolean
areSameTypeInference(ResolvedType a, ResolvedType b)
private <T> java.util.List<java.util.Set<T>>
buildAllSubsetsOfSize(java.util.Set<T> allElements, int desiredSize)
boolean
containsFalse()
BoundSet
deriveImpliedBounds(TypeSolver typeSolver)
static BoundSet
empty()
boolean
equals(java.lang.Object o)
private java.util.Optional<Pair<SameAsBound,SameAsBound>>
findPairSameAs(java.util.function.Predicate<Pair<SameAsBound,SameAsBound>> condition)
private java.util.List<Pair<ResolvedReferenceType,ResolvedReferenceType>>
findPairsOfCommonAncestors(ResolvedReferenceType r1, ResolvedReferenceType r2)
private <T> T
forEachPairSameAndSubtype(BoundSet.Processor<SameAsBound,SubtypeOfBound,T> processor, T initialValue)
private <T> T
forEachPairSameAs(BoundSet.Processor<SameAsBound,SameAsBound,T> processor, T initialValue)
private <T> T
forEachPairSubtypeAndSubtype(BoundSet.Processor<SubtypeOfBound,SubtypeOfBound,T> processor, T initialValue)
private Instantiation
getInstantiationFor(InferenceVariable v)
java.util.List<Bound>
getProperUpperBoundsFor(InferenceVariable inferenceVariable)
int
hashCode()
private boolean
hasInstantiationFor(InferenceVariable v)
private boolean
hasProperty(java.util.Set<InferenceVariable> alphas, java.util.List<BoundSet.VariableDependency> dependencies)
if αi depends on the resolution of a variable β, then either β has an instantiation or there is some j such that β = αjBoundSet
incorporate(BoundSet otherBounds, TypeSolver typeSolver)
Maintains a set of inference variable bounds, ensuring that these are consistent as new bounds are added.boolean
isEmpty()
private boolean
isTheFirstAProperSubsetOfTheSecond(java.util.Set<InferenceVariable> subset, java.util.Set<InferenceVariable> originalSet)
boolean
isTrue()
It is sometimes convenient to refer to an empty bound set with the symbol true; this is merely out of convenience, and the two are interchangeable.java.util.Optional<InstantiationSet>
performResolution(java.util.List<InferenceVariable> variablesToResolve, TypeSolver typeSolver)
Examines the bounds on an inference variable and determines an instantiation that is compatible with those bounds.private boolean
properUpperBoundsAreAtMostExceptionThrowableAndObject(InferenceVariable inferenceVariable)
private java.util.Optional<java.util.Set<InferenceVariable>>
smallestSetWithProperty(java.util.Set<InferenceVariable> uninstantiatedVariables, java.util.List<BoundSet.VariableDependency> dependencies)
there exists no non-empty proper subset of { α1, ..., αn } with this property.private boolean
thereAreProperSubsets(java.util.Set<InferenceVariable> aSet, java.util.Set<java.util.Set<InferenceVariable>> allPossibleSets)
private boolean
thereIsSomeJSuchThatβequalAlphaJ(java.util.Set<InferenceVariable> alphas, InferenceVariable beta)
java.lang.String
toString()
BoundSet
withBound(Bound bound)
-
-
-
Method Detail
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
isTrue
public boolean isTrue()
It is sometimes convenient to refer to an empty bound set with the symbol true; this is merely out of convenience, and the two are interchangeable.
-
empty
public static BoundSet empty()
-
findPairSameAs
private java.util.Optional<Pair<SameAsBound,SameAsBound>> findPairSameAs(java.util.function.Predicate<Pair<SameAsBound,SameAsBound>> condition)
-
isEmpty
public boolean isEmpty()
-
forEachPairSameAs
private <T> T forEachPairSameAs(BoundSet.Processor<SameAsBound,SameAsBound,T> processor, T initialValue)
-
forEachPairSameAndSubtype
private <T> T forEachPairSameAndSubtype(BoundSet.Processor<SameAsBound,SubtypeOfBound,T> processor, T initialValue)
-
forEachPairSubtypeAndSubtype
private <T> T forEachPairSubtypeAndSubtype(BoundSet.Processor<SubtypeOfBound,SubtypeOfBound,T> processor, T initialValue)
-
areSameTypeInference
private boolean areSameTypeInference(ResolvedType a, ResolvedType b)
-
findPairsOfCommonAncestors
private java.util.List<Pair<ResolvedReferenceType,ResolvedReferenceType>> findPairsOfCommonAncestors(ResolvedReferenceType r1, ResolvedReferenceType r2)
-
incorporate
public BoundSet incorporate(BoundSet otherBounds, TypeSolver typeSolver)
Maintains a set of inference variable bounds, ensuring that these are consistent as new bounds are added. Because the bounds on one variable can sometimes impact the possible choices for another variable, this process propagates bounds between such interdependent variables.
-
deriveImpliedBounds
public BoundSet deriveImpliedBounds(TypeSolver typeSolver)
-
containsFalse
public boolean containsFalse()
-
allInferenceVariables
private java.util.Set<InferenceVariable> allInferenceVariables()
-
hasInstantiationFor
private boolean hasInstantiationFor(InferenceVariable v)
-
getInstantiationFor
private Instantiation getInstantiationFor(InferenceVariable v)
-
thereIsSomeJSuchThatβequalAlphaJ
private boolean thereIsSomeJSuchThatβequalAlphaJ(java.util.Set<InferenceVariable> alphas, InferenceVariable beta)
-
buildAllSubsetsOfSize
private <T> java.util.List<java.util.Set<T>> buildAllSubsetsOfSize(java.util.Set<T> allElements, int desiredSize)
-
allButOne
private <T> java.util.Set<T> allButOne(java.util.Set<T> elements, T element)
-
smallestSetWithProperty
private java.util.Optional<java.util.Set<InferenceVariable>> smallestSetWithProperty(java.util.Set<InferenceVariable> uninstantiatedVariables, java.util.List<BoundSet.VariableDependency> dependencies)
there exists no non-empty proper subset of { α1, ..., αn } with this property.
-
hasProperty
private boolean hasProperty(java.util.Set<InferenceVariable> alphas, java.util.List<BoundSet.VariableDependency> dependencies)
if αi depends on the resolution of a variable β, then either β has an instantiation or there is some j such that β = αj- Returns:
-
performResolution
public java.util.Optional<InstantiationSet> performResolution(java.util.List<InferenceVariable> variablesToResolve, TypeSolver typeSolver)
Examines the bounds on an inference variable and determines an instantiation that is compatible with those bounds. It also decides the order in which interdependent inference variables are to be resolved.
-
allPossibleSetsWithProperty
private java.util.Set<java.util.Set<InferenceVariable>> allPossibleSetsWithProperty(java.util.Set<InferenceVariable> allElements, java.util.List<BoundSet.VariableDependency> dependencies)
-
thereAreProperSubsets
private boolean thereAreProperSubsets(java.util.Set<InferenceVariable> aSet, java.util.Set<java.util.Set<InferenceVariable>> allPossibleSets)
-
isTheFirstAProperSubsetOfTheSecond
private boolean isTheFirstAProperSubsetOfTheSecond(java.util.Set<InferenceVariable> subset, java.util.Set<InferenceVariable> originalSet)
-
allSetsWithProperty
private java.util.Set<java.util.Set<InferenceVariable>> allSetsWithProperty(java.util.Set<InferenceVariable> allElements, java.util.List<BoundSet.VariableDependency> dependencies)
-
properUpperBoundsAreAtMostExceptionThrowableAndObject
private boolean properUpperBoundsAreAtMostExceptionThrowableAndObject(InferenceVariable inferenceVariable)
-
appearInLeftPartOfCapture
private boolean appearInLeftPartOfCapture(InferenceVariable inferenceVariable)
-
getProperUpperBoundsFor
public java.util.List<Bound> getProperUpperBoundsFor(InferenceVariable inferenceVariable)
-
-