me.tomassetti.symbolsolver.model.resolution.SymbolReference Maven / Gradle / Ivy
package me.tomassetti.symbolsolver.model.resolution;
import me.tomassetti.symbolsolver.model.declarations.Declaration;
import me.tomassetti.symbolsolver.model.typesystem.TypeUsage;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
/**
* @author Federico Tomassetti
*/
public class SymbolReference {
private Optional extends S> correspondingDeclaration;
private Map typeParametersByName = new HashMap<>();
private SymbolReference(Optional extends S> correspondingDeclaration) {
this.correspondingDeclaration = correspondingDeclaration;
}
public static SymbolReference solved(S2 symbolDeclaration) {
return new SymbolReference(Optional.of(symbolDeclaration));
}
public static SymbolReference unsolved(Class clazz) {
return new SymbolReference(Optional.empty());
}
@Override
public String toString() {
return "SymbolReference{" +
"correspondingDeclaration=" + correspondingDeclaration +
'}';
}
public S getCorrespondingDeclaration() {
if (!isSolved()) {
throw new IllegalStateException();
}
return correspondingDeclaration.get();
}
public boolean isSolved() {
return correspondingDeclaration.isPresent();
}
}