Coverage Report - org.dozer.util.DefaultProxyResolver
 
Classes in this File Line Coverage Branch Coverage Complexity
DefaultProxyResolver
100%
12/12
83%
10/12
3.667
 
 1  
 /**
 2  
  * Copyright 2005-2013 Dozer Project
 3  
  *
 4  
  * Licensed under the Apache License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  *      http://www.apache.org/licenses/LICENSE-2.0
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package org.dozer.util;
 17  
 
 18  
 /**
 19  
  *
 20  
  * Default implementation. Supports only simple proxy cases of Cglib and Javassist.
 21  
  * For more complicated scenarious consider using framework specific ProxyResolver.
 22  
  *
 23  
  * @author dmitry.buzdin
 24  
  */
 25  3
 public class DefaultProxyResolver implements DozerProxyResolver {
 26  
 
 27  
   @Override
 28  
   public boolean isProxy(Class<?> clazz) {
 29  400851
     if (clazz.isInterface()) {
 30  9590
       return false;
 31  
     }
 32  391261
     String className = clazz.getName();
 33  391261
     return className.contains(DozerConstants.CGLIB_ID)
 34  
         || className.startsWith(DozerConstants.JAVASSIST_PACKAGE)
 35  
         || className.contains(DozerConstants.JAVASSIST_SYMBOL);
 36  
   }
 37  
 
 38  
   @Override
 39  
   public <T> T unenhanceObject(T object) {
 40  477304
     return object;
 41  
   }
 42  
 
 43  
   @Override
 44  
   public Class<?> getRealClass(Class<?> clazz) {
 45  400833
     if (isProxy(clazz)) {
 46  21867
       Class<?> superclass = clazz.getSuperclass();
 47  
       // Proxy could be created based on set of interfaces. In this case we will rely on inheritance mappings.
 48  21867
       if (DozerConstants.BASE_CLASS.equals(superclass.getName())) {
 49  7
         return clazz;
 50  
       }
 51  21860
       return superclass;
 52  
     }
 53  378966
     return clazz;
 54  
   }
 55  
 
 56  
 }