Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
class IcicleAssigner {
private final Types typeUtils;
private final Elements elementUtils;
public IcicleAssigner(Types typeUtils, Elements elementUtils) {
this.typeUtils = typeUtils;
this.elementUtils = elementUtils;
}
public boolean isAssignable(String classNameFrom, String classNameTo) {
TypeElement typeFrom = elementUtils.getTypeElement(classNameFrom);
TypeElement typeTo = elementUtils.getTypeElement(classNameTo);
if (typeFrom == null || typeTo == null) {
return false;
}
return typeUtils.isAssignable(typeFrom.asType(), typeTo.asType());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment