private boolean isSubclassOf(final ClassMetadata other) { for (ClassMetadata c = this; c != null; c = c.getSuperclass()) { final ClassMetadata sc = c.getSuperclass(); if (sc != null && sc.type.equals(other.type)) { return true; } } return false; }
private boolean implementsInterface(final ClassMetadata other) { if (this == other) { return true; } for (ClassMetadata c = this; c != null; c = c.getSuperclass()) { for (final ClassMetadata in : c.getInterfaces()) { if (in.type.equals(other.type) || in.implementsInterface(other)) { return true; } } } return false; }
public boolean isAssignableFrom(final ClassMetadata other) { return this == other || other.implementsInterface(this) || other.isSubclassOf(this) || (other.isInterface() && this.type.getDescriptor().equals("Ljava/lang/Object;")); }