Package org.hibernate.annotations.common.test.reflection.java.generics.deep

Source Code of org.hibernate.annotations.common.test.reflection.java.generics.deep.DeepGenericsContainment

//$Id: $
package org.hibernate.annotations.common.test.reflection.java.generics.deep;

import java.util.List;

import junit.framework.TestCase;

import org.hibernate.annotations.common.reflection.XClass;
import org.hibernate.annotations.common.reflection.XProperty;
import org.hibernate.annotations.common.reflection.java.JavaReflectionManager;


/**
* @author Paolo Perrotta
*/
public class DeepGenericsContainment extends TestCase {

  public static class Contained<T> {
      T generic;
  }
 
  public static class Container {
    Contained<String> contained;
  }
 
  public static class ContainerWithCollection {
    List<Contained<String>> contained;
  }

  public void test2StepsGenerics() throws Exception {
    JavaReflectionManager factory = new JavaReflectionManager();
    XClass container = factory.toXClass( Container.class );
    XProperty contained = container.getDeclaredProperties( XClass.ACCESS_FIELD ).get( 0 );
    assertTrue( contained.isTypeResolved() );
    XProperty generic = contained.getType().getDeclaredProperties( XClass.ACCESS_FIELD ).get( 0 );
    assertTrue( generic.isTypeResolved() );
  }

  public void test2StepsGenericsCollection() throws Exception {
    JavaReflectionManager factory = new JavaReflectionManager();
    XClass container = factory.toXClass( ContainerWithCollection.class );
    XProperty collection = container.getDeclaredProperties( XClass.ACCESS_FIELD ).get( 0 );
    assertTrue( collection.isTypeResolved() );
    XClass elementClass = collection.getElementClass();
    XProperty generic = elementClass.getDeclaredProperties( XClass.ACCESS_FIELD ).get( 0 );
    assertTrue( generic.isTypeResolved() );
  }
}
TOP

Related Classes of org.hibernate.annotations.common.test.reflection.java.generics.deep.DeepGenericsContainment

TOP
Copyright © 2018 www.massapi.com. 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.