Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package org.skife.jdbi.v2.sqlobject.customizers;
 
 
Used to set attributes on the StatementContext for the statement generated for this method. These values will be available to other customizers, such as the statement locator or rewriter.
public @interface RegisterArgumentFactory
{
    
The key for the attribute to set. The value will be the value passed to the annotated argument
    Class<? extends ArgumentFactory>[] value();
    static class Factory implements SqlStatementCustomizerFactory
    {
        public SqlStatementCustomizer createForType(Annotation annotationClass sqlObjectType)
        {
            return create(annotation);
        }
        public SqlStatementCustomizer createForMethod(Annotation annotationClass sqlObjectTypeMethod method)
        {
            return create(annotation);
        }
        public SqlStatementCustomizer createForParameter(Annotation annotationClass sqlObjectTypeMethod methodfinal Object arg)
        {
            throw new IllegalStateException("not allowed on parameter");
        }
        private SqlStatementCustomizer create(Annotation annotation)
        {
            final RegisterArgumentFactory raf = (RegisterArgumentFactoryannotation;
            final List<ArgumentFactoryary = new ArrayList<ArgumentFactory>(raf.value().length);
            for (Class<? extends ArgumentFactoryaClass : raf.value()) {
                try {
                    ary.add(aClass.newInstance());
                }
                catch (Exception e) {
                    throw new IllegalStateException("unable to instantiate specified argument factory"e);
                }
            }
            return new SqlStatementCustomizer()
            {
                public void apply(SQLStatement qthrows SQLException
                {
                    for (ArgumentFactory argumentFactory : ary) {
                        q.registerArgumentFactory(argumentFactory);
                    }
                }
            };
        }
    }
New to GrepCode? Check out our FAQ X