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 interfaceBoundSet.Processor<B1 extends Bound,B2 extends Bound,R>private classBoundSet.VariableDependency
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<Bound>boundsprivate static BoundSetEMPTYprivate static java.lang.StringJAVA_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 booleanappearInLeftPartOfCapture(InferenceVariable inferenceVariable)private booleanareSameTypeInference(ResolvedType a, ResolvedType b)private <T> java.util.List<java.util.Set<T>>buildAllSubsetsOfSize(java.util.Set<T> allElements, int desiredSize)booleancontainsFalse()BoundSetderiveImpliedBounds(TypeSolver typeSolver)static BoundSetempty()booleanequals(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> TforEachPairSameAndSubtype(BoundSet.Processor<SameAsBound,SubtypeOfBound,T> processor, T initialValue)private <T> TforEachPairSameAs(BoundSet.Processor<SameAsBound,SameAsBound,T> processor, T initialValue)private <T> TforEachPairSubtypeAndSubtype(BoundSet.Processor<SubtypeOfBound,SubtypeOfBound,T> processor, T initialValue)private InstantiationgetInstantiationFor(InferenceVariable v)java.util.List<Bound>getProperUpperBoundsFor(InferenceVariable inferenceVariable)inthashCode()private booleanhasInstantiationFor(InferenceVariable v)private booleanhasProperty(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 β = αjBoundSetincorporate(BoundSet otherBounds, TypeSolver typeSolver)Maintains a set of inference variable bounds, ensuring that these are consistent as new bounds are added.booleanisEmpty()private booleanisTheFirstAProperSubsetOfTheSecond(java.util.Set<InferenceVariable> subset, java.util.Set<InferenceVariable> originalSet)booleanisTrue()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 booleanproperUpperBoundsAreAtMostExceptionThrowableAndObject(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 booleanthereAreProperSubsets(java.util.Set<InferenceVariable> aSet, java.util.Set<java.util.Set<InferenceVariable>> allPossibleSets)private booleanthereIsSomeJSuchThatβequalAlphaJ(java.util.Set<InferenceVariable> alphas, InferenceVariable beta)java.lang.StringtoString()BoundSetwithBound(Bound bound)
-
-
-
Method Detail
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin 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)
-
-