/** * Gets the appropriate {@link Type} for the given class. * * @param klass The class * @return The type */ static Type of(final Class<?> klass) { if (klass.isPrimitive() && klass == Void.TYPE) { return VoidType.INSTANCE; } return FieldType.of(klass); }
/** * Creates a new field signature with the given name and * decoded type descriptor. * * @param name The name of the field * @param type The raw type of the field * @return The new field signature */ public static FieldSignature of(String name, String type) { return new FieldSignature(name, FieldType.of(type)); }
/** * Gets, or creates should it not exist, a field mapping of the * given signature. * * @param obfuscatedName The obfuscated name of the field mapping * @param obfuscatedDescriptor The obfuscated descriptor of the field mapping * @return The field mapping * @since 0.4.0 */ default FieldMapping getOrCreateFieldMapping(final String obfuscatedName, final String obfuscatedDescriptor) { return this.getOrCreateFieldMapping(new FieldSignature(obfuscatedName, FieldType.of(obfuscatedDescriptor))); }
private void readClass(final ClassMapping mapping) throws IOException { mapping.setDeobfuscatedName(this.stream.readUTF()); final int classCount = this.stream.readInt(); for (int i = 0; i < classCount; i++) { this.readClass(mapping.getOrCreateInnerClassMapping(this.stream.readUTF())); } final int fieldCount = this.stream.readInt(); for (int i = 0; i < fieldCount; i++) { final FieldMapping field; final String obf = this.stream.readUTF(); // has type info // todo: clean this up (introduce more convenience methods to ClassMapping) if (this.stream.readBoolean()) { field = mapping.getOrCreateFieldMapping(new FieldSignature(obf, FieldType.of(this.stream.readUTF()))); } else { field = mapping.getOrCreateFieldMapping(obf); } field.setDeobfuscatedName(this.stream.readUTF()); } final int methodCount = this.stream.readInt(); for (int i = 0; i < methodCount; i++) { mapping.getOrCreateMethodMapping(this.stream.readUTF(), this.stream.readUTF()) .setDeobfuscatedName(this.stream.readUTF()); } }
final String obfName = split[1]; final String deobfName = split[2]; final String type = handleNonePrefix(FieldType.of(split[3])).toString(); this.peekClass().getOrCreateFieldMapping(obfName, type) .setDeobfuscatedName(deobfName);