Example usage for java.lang.reflect TypeVariable TypeVariable

List of usage examples for java.lang.reflect TypeVariable TypeVariable

Introduction

In this page you can find the example usage for java.lang.reflect TypeVariable TypeVariable.

Prototype

TypeVariable

Source Link

Usage

From source file:org.evosuite.utils.TestGenericClass.java

@SuppressWarnings("rawtypes")
@Test//  w w w.j ava2s  .c  om
public void testIterableAndListBoundaries() {
    Map<TypeVariable<?>, Type> typeMap = new HashMap<TypeVariable<?>, Type>();
    final GenericClass iterableIntegerClass = new GenericClass(new TypeToken<java.lang.Iterable<Integer>>() {
    }.getType());

    TypeVariable<?> var = new TypeVariable() {

        public AnnotatedType[] getAnnotatedBounds() {
            return null;
        }

        @Override
        public Type[] getBounds() {
            return new Type[] { iterableIntegerClass.getType() };
        }

        @Override
        public GenericDeclaration getGenericDeclaration() {
            // TODO Auto-generated method stub
            return null;
        }

        @Override
        public String getName() {
            return "Test";
        }

        /* (non-Javadoc)
         * @see java.lang.Object#toString()
         */
        @Override
        public String toString() {
            return "Dummy Variable";
        }

        public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
            // TODO Auto-generated method stub
            return null;
        }

        public Annotation[] getAnnotations() {
            // TODO Auto-generated method stub
            return null;
        }

        public Annotation[] getDeclaredAnnotations() {
            // TODO Auto-generated method stub
            return null;
        }

        //public void getAnnotatedBounds() {
        // TODO Auto-generated method stub
        //}

    };

    typeMap.put(var, iterableIntegerClass.getType());

    GenericClass arrayListClass = new GenericClass(new TypeToken<java.util.ArrayList<String>>() {
    }.getType());

    Assert.assertFalse(arrayListClass.satisfiesBoundaries(var, typeMap));

    arrayListClass = new GenericClass(new TypeToken<java.util.ArrayList<Integer>>() {
    }.getType());

    Assert.assertTrue(arrayListClass.satisfiesBoundaries(var, typeMap));

}