return new ObjectType(klass.getName());
@Override public boolean isInstanceOf(final Type obj, final InheritanceProvider inheritanceProvider) { if (this == obj) return true; if (!(obj instanceof ObjectType)) return false; final ObjectType that = (ObjectType) obj; return this.equals(that) || that.getClassName().equals("java/lang/Object") || inheritanceProvider.getParentsOf(this.className).contains(that.getClassName()); }
private static FieldType handleNonePrefix(final FieldType type) { if (type instanceof ArrayType) { final ArrayType arr = (ArrayType) type; return new ArrayType(arr.getDimCount(), handleNonePrefix(arr.getComponent())); } if (type instanceof ObjectType) { final ObjectType obj = (ObjectType) type; return new ObjectType(handleNonePrefix(obj.getClassName())); } return type; }
/** * Gets the de-obfuscated raw view of the type. * * @param type The type to de-obfuscate * @return The de-obfuscated raw view * @since 0.4.0 */ default String deobfuscate(final Type type) { if (type instanceof ArrayType) { final ArrayType arr = (ArrayType) type; return arr.getDims() + this.deobfuscate(arr.getComponent()); } else if (type instanceof ObjectType) { final ObjectType obj = (ObjectType) type; final Optional<? extends ClassMapping<?>> typeMapping = this.getClassMapping(obj.getClassName()); return "L" + typeMapping.map(Mapping::getFullDeobfuscatedName).orElse(obj.getClassName()) + ";"; } return type.toString(); }
private static FieldType handleNonePrefix(final FieldType type) { if (type instanceof ArrayType) { final ArrayType arr = (ArrayType) type; return new ArrayType(arr.getDimCount(), handleNonePrefix(arr.getComponent())); } if (type instanceof ObjectType) { final ObjectType obj = (ObjectType) type; return new ObjectType(handleNonePrefix(obj.getClassName())); } return type; }
/** * Reads the next {@link ObjectType} from source. * * @return The type * @throws IllegalStateException If the descriptor is invalid */ public ObjectType readObjectType() { final int start = this.current; this.advance(); while (this.hasNext() && this.peek() != ';') { this.advance(); } if (this.peek() != ';') throw new IllegalStateException("Incomplete descriptor provided!"); this.advance(); return new ObjectType(this.source.substring(start + 1, this.current - 1)); }