Coverage Report - org.dozer.util.HibernateProxyResolver
 
Classes in this File Line Coverage Branch Coverage Complexity
HibernateProxyResolver
0%
0/7
0%
0/2
2
 
 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  
 import org.hibernate.proxy.HibernateProxy;
 19  
 import org.hibernate.proxy.HibernateProxyHelper;
 20  
 import org.hibernate.proxy.LazyInitializer;
 21  
 
 22  
 /**
 23  
  *
 24  
  * Hibernate specific implementation. Checks for HibernateProxy interface and uses Hibernate internal API
 25  
  * to unwrap proxies. 
 26  
  *
 27  
  * @author Dmitry Buzdin
 28  
  */
 29  0
 public class HibernateProxyResolver extends DefaultProxyResolver {
 30  
 
 31  
   @Override
 32  
   public boolean isProxy(Class<?> clazz) {
 33  0
     return HibernateProxy.class.isAssignableFrom(clazz);
 34  
   }
 35  
 
 36  
   @Override
 37  
   public <T> T unenhanceObject(T object) {
 38  0
     if (object instanceof HibernateProxy) {
 39  0
       HibernateProxy hibernateProxy = (HibernateProxy) object;
 40  0
       LazyInitializer lazyInitializer = hibernateProxy.getHibernateLazyInitializer();
 41  
 
 42  0
       return (T) lazyInitializer.getImplementation();
 43  
     }
 44  0
     return object;
 45  
   }
 46  
 
 47  
 }