// Generated by delombok at Sun Feb 26 12:31:38 KST 2017
package scouter.bytebuddy.dynamic.scaffold.inline;
import scouter.bytebuddy.description.method.MethodDescription;
import scouter.bytebuddy.utility.RandomString;
/**
* A method name transformer provides a unique mapping of a method's name to an alternative name.
*
* @see MethodRebaseResolver
*/
public interface MethodNameTransformer {
/**
* Transforms a method's name to an alternative name. This name must not be equal to any existing method of the
* created class.
*
* @param methodDescription The original method.
* @return The alternative name.
*/
String transform(MethodDescription methodDescription);
/**
* A method name transformer that adds a fixed suffix to an original method name, separated by a {@code $}.
*/
class Suffixing implements MethodNameTransformer {
/**
* The default suffix to add to an original method name.
*/
private static final String DEFAULT_SUFFIX = "original$";
/**
* The suffix to append to a method name.
*/
private final String suffix;
/**
* Creates a new suffixing method name transformer which adds a default suffix with a random name component.
*
* @return A method name transformer that adds a randomized suffix to the original method name.
*/
public static MethodNameTransformer withRandomSuffix() {
return new Suffixing(DEFAULT_SUFFIX + RandomString.make());
}
/**
* Creates a new suffixing method name transformer.
*
* @param suffix The suffix to add to the method name before the seed.
*/
public Suffixing(String suffix) {
this.suffix = suffix;
}
@Override
public String transform(MethodDescription methodDescription) {
return String.format("%s$%s", methodDescription.getInternalName(), suffix);
}
@java.lang.Override
@java.lang.SuppressWarnings("all")
@javax.annotation.Generated("lombok")
public boolean equals(final java.lang.Object o) {
if (o == this) return true;
if (!(o instanceof MethodNameTransformer.Suffixing)) return false;
final MethodNameTransformer.Suffixing other = (MethodNameTransformer.Suffixing) o;
if (!other.canEqual((java.lang.Object) this)) return false;
final java.lang.Object this$suffix = this.suffix;
final java.lang.Object other$suffix = other.suffix;
if (this$suffix == null ? other$suffix != null : !this$suffix.equals(other$suffix)) return false;
return true;
}
@java.lang.SuppressWarnings("all")
@javax.annotation.Generated("lombok")
protected boolean canEqual(final java.lang.Object other) {
return other instanceof MethodNameTransformer.Suffixing;
}
@java.lang.Override
@java.lang.SuppressWarnings("all")
@javax.annotation.Generated("lombok")
public int hashCode() {
final int PRIME = 59;
int result = 1;
final java.lang.Object $suffix = this.suffix;
result = result * PRIME + ($suffix == null ? 43 : $suffix.hashCode());
return result;
}
}
/**
* A method name transformer that adds a fixed prefix to an original method name.
*/
class Prefixing implements MethodNameTransformer {
/**
* The default prefix to add to an original method name.
*/
private static final String DEFAULT_PREFIX = "original";
/**
* The prefix that is appended.
*/
private final String prefix;
/**
* Creates a new prefixing method name transformer using a default prefix.
*/
public Prefixing() {
this(DEFAULT_PREFIX);
}
/**
* Creates a new prefixing method name transformer.
*
* @param prefix The prefix being used.
*/
public Prefixing(String prefix) {
this.prefix = prefix;
}
@Override
public String transform(MethodDescription methodDescription) {
return String.format("%s%s", prefix, methodDescription.getInternalName());
}
@java.lang.Override
@java.lang.SuppressWarnings("all")
@javax.annotation.Generated("lombok")
public boolean equals(final java.lang.Object o) {
if (o == this) return true;
if (!(o instanceof MethodNameTransformer.Prefixing)) return false;
final MethodNameTransformer.Prefixing other = (MethodNameTransformer.Prefixing) o;
if (!other.canEqual((java.lang.Object) this)) return false;
final java.lang.Object this$prefix = this.prefix;
final java.lang.Object other$prefix = other.prefix;
if (this$prefix == null ? other$prefix != null : !this$prefix.equals(other$prefix)) return false;
return true;
}
@java.lang.SuppressWarnings("all")
@javax.annotation.Generated("lombok")
protected boolean canEqual(final java.lang.Object other) {
return other instanceof MethodNameTransformer.Prefixing;
}
@java.lang.Override
@java.lang.SuppressWarnings("all")
@javax.annotation.Generated("lombok")
public int hashCode() {
final int PRIME = 59;
int result = 1;
final java.lang.Object $prefix = this.prefix;
result = result * PRIME + ($prefix == null ? 43 : $prefix.hashCode());
return result;
}
}
}