org.hotswap.agent.plugin.mybatis.util.ClassUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hotswap-agent-mybatis-plugin Show documentation
Show all versions of hotswap-agent-mybatis-plugin Show documentation
Java unlimited runtime class and resource redefinition.
The newest version!
package org.hotswap.agent.plugin.mybatis.util;
import org.hotswap.agent.javassist.*;
public class ClassUtils {
public static void addFieldNotExists(CtClass ctClass, CtField ctField) throws CannotCompileException {
if (fieldExists(ctClass, ctField.getName())) {
return;
}
ctClass.addField(ctField);
}
public static boolean fieldExists(CtClass ctClass, String fieldName) {
try {
return ctClass.getDeclaredField(fieldName) != null;
} catch (NotFoundException e) {
return false;
}
}
public static boolean methodExists(CtClass ctClass, String methodName, CtClass[] params) {
try {
return ctClass.getDeclaredMethod(methodName, params) != null;
} catch (NotFoundException e) {
return false;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy