Package javassist

Examples of javassist.CtClass.addMethod()


            {
                CtMethod method = (CtMethod)allMethods.next();
                CtMethod newMethod = new CtMethod(method, ctTranslatorClass, null);
                String methodBody = (String)this.methods.get(method);
                newMethod.setBody(methodBody);
                ctTranslatorClass.addMethod(newMethod);
            }

        }
        this.writeAdaptedClass();
        return ctTranslatorClass.toClass();
View Full Code Here


        CtMethod method = new CtMethod(pool.get("java.lang.String"), "getStatus", null, ctClass);

        method.setBody(String.format("return \"%s\";", status));

        ctClass.addMethod(method);

        ctClass.writeFile(classesDir.getAbsolutePath());
    }

    private void createInvalidImplentationClass() throws Exception
View Full Code Here

        CtMethod method = new CtMethod(pool.get("java.lang.String"), "getStatus", null, ctClass);

        method.setBody("return \"unreachable\";");

        ctClass.addMethod(method);

        CtConstructor constructor = new CtConstructor(new CtClass[0], ctClass);

        constructor.setBody("return $0;");
View Full Code Here

        // all
        try {
          ctClass.getDeclaredMethod("all");
        }catch(NotFoundException ex){
            CtMethod all = CtMethod.make("public static play.modules.siena.QueryWrapper all() { return new play.modules.siena.QueryWrapper(siena.Model.all("+entityName+".class)); }", ctClass);
            ctClass.addMethod(all);         
        }
 
        // batch
        try {
          ctClass.getDeclaredMethod("batch");
View Full Code Here

        // batch
        try {
          ctClass.getDeclaredMethod("batch");
        }catch(NotFoundException ex){
          CtMethod batch = CtMethod.make("public static play.modules.siena.BatchWrapper batch() { return new play.modules.siena.BatchWrapper(siena.Model.batch("+entityName+".class)); }", ctClass);
          ctClass.addMethod(batch);
        }
       
        // getbyKey
        try {
          ctClass.getDeclaredMethod("getByKey");
View Full Code Here

        // getbyKey
        try {
          ctClass.getDeclaredMethod("getByKey");
        }catch(NotFoundException ex){
          CtMethod batch = CtMethod.make("public static play.modules.siena.EnhancedModel getByKey(Object key) { return (play.modules.siena.EnhancedModel)siena.Model.getByKey("+entityName+".class, key); }", ctClass);
          ctClass.addMethod(batch);
        }

        // create
        try {
          ctClass.getDeclaredMethod("create");
View Full Code Here

        // create
        try {
          ctClass.getDeclaredMethod("create");
        }catch(NotFoundException ex){
            CtMethod create = CtMethod.make("public static play.modules.siena.EnhancedModel create(String name, play.mvc.Scope.Params params) { return play.modules.siena.EnhancedModel.create("+entityName+".class, name, params.all()); }",ctClass);
            ctClass.addMethod(create);
        }


        // count
        try {
View Full Code Here

        // count
        try {
          ctClass.getDeclaredMethod("count");
        }catch(NotFoundException ex){
          CtMethod count = CtMethod.make("public static long count() { return (long)siena.Model.all("+entityName+".class).count(); }", ctClass);
          ctClass.addMethod(count);
        }

        // findAll
        try {
          ctClass.getDeclaredMethod("findAll");
View Full Code Here

        // findAll
        try {
          ctClass.getDeclaredMethod("findAll");
        }catch(NotFoundException ex){
          CtMethod findAll = CtMethod.make("public static java.util.List findAll() { return (java.util.List)siena.Model.all("+entityName+".class).fetch(); }", ctClass);
          ctClass.addMethod(findAll);
        }

        // deleteAll
        try {
          ctClass.getDeclaredMethod("deleteAll");
View Full Code Here

        // deleteAll
        try {
          ctClass.getDeclaredMethod("deleteAll");
       }catch(NotFoundException ex){
          CtMethod deleteAll = CtMethod.make("public static long deleteAll() { return (long)siena.Model.all("+entityName+".class).delete(); }", ctClass);
          ctClass.addMethod(deleteAll);
        }
 
        // findById
       try {
         ctClass.getDeclaredMethod("findById");
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.