Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * Copyright 2010 the original author or authors.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
  *      http://www.apache.org/licenses/LICENSE-2.0
  *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.callbackparams.convert;

Author(s):
Henrik Kaipe
public interface InjectedConvertStrategy extends ConvertStrategy {
    Factory FACTORY = new Factory() {};
    public Class testClass();
    public Class callbackInterface();
    public Method callbackMethod();
    abstract class Factory {
        private final String NEW_INJECTED_CLASS_NAME =
                Injected.class.getPackage().getName() + "._new_injected_name";
        private final ClassConstantModifyingVisitor INJECTED_CLASS_CHANGER =
                new ClassConstantModifyingVisitor(
                Injected.class.getName(), );
        private final Class template = InjectedConvertStrategyTemplate.class;

        
Creates a new StrategyConverter instance that will be with

Parameters:
converterStrategyClass
testClass
testMethod
parameterIndex
Returns:
                final Class convertStrategyClassfinal Class testClass,
                final Method callbackMethodfinal Integer parameterIndex) {
            if (false == Modifier
                    .isPublic(convertStrategyClass.getModifiers())) {
                throw new IllegalArgumentException(
                        convertStrategyClass + " is not public");
            } else if (false == ConvertStrategy.class
                    .isAssignableFrom(convertStrategyClass)) {
                throw new IllegalArgumentException(convertStrategyClass
                        + " does not implement " + ConvertStrategy.class);
            }
            Class newInjectedClass = TemplateBasedClassBuilder.newBuilder(
                    convertStrategyClass.getClassLoader(), Injected.class)
                    .setNewClassName()
                    .wrapClass().getWrappedClass();
            try {
                newInjectedClass.getConstructors()[0].newInstance(new Object[] {
                    testClasscallbackMethodparameterIndex
                });
            } catch (Exception wtf) {
                throw new Error(wtf);
            }
            ClassConstantModifyingVisitor templateSuperClassChanger =
                    new ClassConstantModifyingVisitor(
                    DummyConverter.classconvertStrategyClass);
            return (InjectedConvertStrategy) TemplateBasedClassBuilder
                    .newBuilder(newInjectedClass.getClassLoader(), )
                    .applyVisitor()
                    .applyVisitor(templateSuperClassChanger)
                    .wrapClass().newInstance();
        }
    }
New to GrepCode? Check out our FAQ X