Package ma.glasnost.orika.unenhance

Examples of ma.glasnost.orika.unenhance.BaseUnenhancer


     *
     * @return the resulting UnenhanceStrategy
     */
    protected UnenhanceStrategy buildUnenhanceStrategy(UnenhanceStrategy unenhanceStrategy, SuperTypeResolverStrategy superTypeStrategy) {
       
        BaseUnenhancer unenhancer = new BaseUnenhancer();
       
        if (unenhanceStrategy != null) {
            unenhancer.addUnenhanceStrategy(unenhanceStrategy);
        }
       
        if (superTypeStrategy != null) {
            unenhancer.addSuperTypeResolverStrategy(superTypeStrategy);
        }
//        else {
//           
//            /*
//             * This strategy attempts to lookup super-type that has a registered
//             * mapper or converter whenever it is offered a class that is not
//             * currently mapped
//             */
//            final SuperTypeResolverStrategy registeredMappersStrategy = new DefaultSuperTypeResolverStrategy() {
//               
//                @Override
//                public boolean isAcceptable(Type<?> type) {
//                    return type != null && aToBRegistry.containsKey(type);
//                }
//            };
//           
//            unenhancer.addSuperTypeResolverStrategy(registeredMappersStrategy);
//        }
       
        /*
         * This strategy produces super-types whenever the proposed class type
         * is not accessible to the compilerStrategy and/or the current thread
         * context class-loader; it is added last as a fail-safe in case a
         * suggested type cannot be used. It is automatically included, as
         * there's no case when skipping it would be desired....
         */
        final SuperTypeResolverStrategy inaccessibleTypeStrategy = new DefaultSuperTypeResolverStrategy() {
           
            /**
             * Tests whether the specified type is accessible to both the
             * current thread's class-loader, and also to the compilerStrategy.
             *
             * @param type
             * @return true if the type is accessible
             */
            public boolean isTypeAccessible(Type<?> type) {
               
                try {
                    compilerStrategy.assureTypeIsAccessible(type.getRawType());
                    return true;
                } catch (SourceCodeGenerationException e) {
                    return false;
                }
            }
           
            @Override
            public boolean isAcceptable(Type<?> type) {
                return isTypeAccessible(type) && !java.lang.reflect.Proxy.class.equals(type.getRawType());
            }
           
        };
       
        unenhancer.addSuperTypeResolverStrategy(inaccessibleTypeStrategy);
       
        return unenhancer;
       
    }
View Full Code Here

TOP

Related Classes of ma.glasnost.orika.unenhance.BaseUnenhancer

Copyright © 2018 www.massapicom. 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.