@Override public boolean equals(Object obj) { if (!(obj instanceof SClass)) { return false; } SClass that = (SClass) obj; return getDescriptor().equals(that.getDescriptor()); }
public String toMethodDescriptorString() { StringBuilder sb = new StringBuilder(); sb.append("("); for (SClass<?> c : parameters) { sb.append(c.getDescriptor()); } sb.append(")"); sb.append(returnType.getDescriptor()); return sb.toString(); }
private boolean implementsInterface(SClass<?> interfaze) { if (this.equals(interfaze)) { return true; } for (SClass<?> ifs : this.getInterfaces()) { if (ifs.implementsInterface(interfaze)) { return true; } } SClass<?> superclass = getSuperclass(); return superclass != null ? superclass.implementsInterface(interfaze) : false; }
@Override public SClass getSuperclass() { if (isPrimitive() || isInterface()) { return null; } return SClass.lookup0(descriptor).getSuperclass(); }
public final boolean isAssignableFrom(SClass<?> that) { if (this == that) { return true; } String thisDescriptor = this.getDescriptor(); String thatDescriptor = that.getDescriptor(); if (thisDescriptor.equals(thatDescriptor)) { return true; } if (this.isPrimitive() || that.isPrimitive()) { return false; } if (ObjectClass.getDescriptor().equals(thisDescriptor)) { return true; } if (this.isArray()) { if (!that.isArray()) { return false; } return this.getComponentType().isAssignableFrom(that.getComponentType()); } if (this.isInterface()) { return that.implementsInterface(this); } SClass<?> superclass = that.getSuperclass(); while (superclass != null) { if (superclass.getDescriptor().equals(thisDescriptor)) { return true; } superclass = superclass.getSuperclass(); } return false; }
@Override public SClass[] getInterfaces() { return SClass.lookup0(descriptor).getInterfaces(); }