Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2012 Sonatype, Inc. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html Contributors: Stuart McCulloch /
 
 
 package org.kohsuke.stapler;
 
 import java.util.Set;
 
 
Generates stapler files for DataBoundConstructor classes.

Author(s):
Stuart McCulloch
 
 public final class DataBoundConstructorAPT6
     extends AbstractAPT6
 {
     @Override
     public boolean processfinal Set<? extends TypeElementannotationsfinal RoundEnvironment round )
     {
         for ( final Element element : round.getRootElements() )
         {
             .visitelementthis );
         }
         return false;
     }
 
     private static final ElementVisitor<VoidDataBoundConstructorAPT6SCANNER =
         new ElementScanner6<VoidDataBoundConstructorAPT6>()
         {
             @Override
             public Void visitExecutablefinal ExecutableElement methodfinal DataBoundConstructorAPT6 self )
             {
                 if ( method.getAnnotationDataBoundConstructor.class ) != null )
                 {
                     self.storenew DataBoundConstructorContentmethod ) );
                 }
                 else if ( method.getKind() == . )
                 {
                     final String javadoc = self.javadocmethod );
                     if ( javadoc != null && javadoc.contains"@stapler-constructor" ) )
                     {
                         self.storenew DataBoundConstructorContentmethod ) );
                     }
                 }
                 return super.visitExecutablemethodself );
             }
         };
 }

Generates DataBoundConstructor stapler content.
 
     implements Content
 {
     private final ExecutableElement ctor;
 
     {
         this. = ctor;
     }
 
     public String location()
     {
         final TypeElement clazz = (TypeElement.getEnclosingElement();
         final String path = clazz.getQualifiedName().toString().replace'.''/' );
         return path + ".stapler";
    }
    public void loadfinal InputStream is )
    {
        // nothing to do
    }
    public void storefinal OutputStream os )
        throws IOException
    {
        final StringBuilder buf = new StringBuilder();
        for ( final VariableElement var : .getParameters() )
        {
            if ( buf.length() > 0 )
            {
                buf.append',' );
            }
            buf.appendvar.getSimpleName() );
        }
        final Properties props = new Properties();
        props.put"constructor"buf.toString() );
        props.storeosnull );
    }
New to GrepCode? Check out our FAQ X