/** * Creates a method signature, with the given raw string that contains the * method name and descriptor concatenated. * * @param nameAndDescriptor The method name and descriptor * @return The new method signature */ public static MethodSignature of(final String nameAndDescriptor) { int methodIndex = nameAndDescriptor.indexOf('('); return of(nameAndDescriptor.substring(0, methodIndex), nameAndDescriptor.substring(methodIndex)); }
/** * Creates a new method mapping, from the given parameters. * * @param parentClass The class mapping, this mapping belongs to * @param signature The signature * @param deobfuscatedName The de-obfuscated name */ public MethodMappingImpl(final ClassMapping parentClass, final MethodSignature signature, final String deobfuscatedName) { super(parentClass, signature.getName(), deobfuscatedName); this.signature = signature; }
/** * Creates a method signature, with the given method name and raw descriptor. * * @param name The method name * @param descriptor The method's raw descriptor * @return The new method signature */ public static MethodSignature of(final String name, final String descriptor) { return new MethodSignature(name, MethodDescriptor.of(descriptor)); }
/** * Gets the {@link MethodDescriptor} of the method. * * @return The method descriptor * @see MethodSignature#getDescriptor() */ default MethodDescriptor getDescriptor() { return this.getSignature().getDescriptor(); }
/** * Gets, or creates should it not exist, a method mapping of the * given obfuscated name, and descriptor. * * @param obfuscatedName The obfuscated name of the method mapping * @param obfuscatedDescriptor The obfuscated descriptor of the method mapping * @return The method mapping */ default MethodMapping getOrCreateMethodMapping(final String obfuscatedName, final String obfuscatedDescriptor) { return this.getOrCreateMethodMapping(MethodSignature.of(obfuscatedName, obfuscatedDescriptor)); }
/** * Creates a new method mapping, attached to this class mapping, using * the given method signature. * * @param signature The method signature * @return The method mapping */ default MethodMapping createMethodMapping(final MethodSignature signature) { return this.createMethodMapping(signature, signature.getName()); }
/** * Creates a new method mapping, attached to this class mapping, using * the given obfuscated method name and descriptor. * * @param obfuscatedName The obfuscated method name * @param obfuscatedDescriptor The obfuscated method descriptor * @return The method mapping */ default MethodMapping createMethodMapping(final String obfuscatedName, final String obfuscatedDescriptor) { return this.createMethodMapping(MethodSignature.of(obfuscatedName, obfuscatedDescriptor)); }