Example #1
0
 @Override
 public boolean equals(Object obj) {
   if (!(obj instanceof SClass)) {
     return false;
   }
   SClass that = (SClass) obj;
   return getDescriptor().equals(that.getDescriptor());
 }
Example #2
0
 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();
 }
Example #3
0
 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;
 }
Example #4
0
 @Override
 public SClass getSuperclass() {
   if (isPrimitive() || isInterface()) {
     return null;
   }
   return SClass.lookup0(descriptor).getSuperclass();
 }
Example #5
0
  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;
  }
Example #6
0
 @Override
 public SClass[] getInterfaces() {
   return SClass.lookup0(descriptor).getInterfaces();
 }