Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package net.sf.alchim.codeplus.spoonprocessor;
 
 
This processor inserts the getters and the setters typical implementations for all the fields annotated with the spoon.examples.fieldaccess.annotation.Access annotation.
public class StupidGetSetGenerator<_FieldType_> extends AbstractProcessor<CtField<_FieldType_>> {
    public static ArrayList<CtClass<?>> targetClasses_ = new ArrayList<CtClass<?>>();
    @Property
    public boolean generateOnlyOnAnnotation = true;

    
TODO: check if getter and setter not exist
    public void process(CtField<_FieldType_> field) {
        try {
            CtClass<?> parent = field.getParent(CtClass.class);
            if (!.contains(parent)) {
                CtAnnotation<?> annotation = ProcessorHelper.findAnnotation(parentGenStupidGetSet.class);
                if ( && (annotation == null)) {
                    return;
                }
                .add(parent);
                ProcessorHelper.removeAnnotation(parentGenStupidGetSet.class);
            }
            if (field.getModifiers().contains(.)) {
                return;
            }
            if (field.getModifiers().contains(.)) {
                return;
            }
            if (!field.getModifiers().contains(.)) {
                return;
            }
            // fields.add(field.getReference());
            Substitution.insertAll(field.getParent(CtClass.class), new StupidGetSetTemplate<_FieldType_>(field.getType(), field.getSimpleName()));
        } catch (Exception exc) {
            throw new ProcessingException(thisfieldexc);
        }
    }
New to GrepCode? Check out our FAQ X