Example usage for org.apache.commons.lang3.reflect TypeUtils equals

List of usage examples for org.apache.commons.lang3.reflect TypeUtils equals

Introduction

In this page you can find the example usage for org.apache.commons.lang3.reflect TypeUtils equals.

Prototype

private static boolean equals(final Type[] t1, final Type[] t2) 

Source Link

Document

Learn whether t1 equals t2 .

Usage

From source file:org.lambdamatic.mongodb.apt.testutil.FieldAssertion.java

/**
 * Checks that the actual field is parameterized.
 * //from  w w w.ja  v  a 2 s  . c  o  m
 * @param expectedRawType the expected raw type
 * @param expectedTypeArguments the expected type arguments
 * @return this {@link FieldAssertion} for fluent linking
 */
public FieldAssertion isParameterizedType(final Class<?> expectedRawType, final Type... expectedTypeArguments) {
    isNotNull();
    if (!(actual.getGenericType() instanceof ParameterizedType)) {
        failWithMessage("Expected field <%s> to be a parameterized type but it was not", actual);
    }
    final ParameterizedType actualType = (ParameterizedType) actual.getGenericType();
    final ParameterizedType expectedParameterizedType = TypeUtils.parameterize(expectedRawType,
            expectedTypeArguments);
    if (!TypeUtils.equals(actualType, expectedParameterizedType)) {
        failWithMessage("Expected field %s.%s to be of type %s<%s> but it was %s<%s>",
                actual.getType().getName(), actual.getName(), expectedRawType, expectedTypeArguments,
                actualType.getRawType().getTypeName(), actualType.getActualTypeArguments());
    }
    return this;
}

From source file:therian.operator.getelementtype.GetArrayElementTypeTest.java

@Test
public void test() {
    assertEquals(int.class, therianContext.eval(GetElementType.of(new TypeLiteral<int[]>() {
    })));/*  ww  w  .  j a  va2s . c om*/
    assertEquals(String.class, therianContext.eval(GetElementType.of(new TypeLiteral<String[]>() {
    })));
    assertTrue(TypeUtils.equals(new TypeLiteral<List<String>>() {
    }.value, therianContext.eval(GetElementType.of(new TypeLiteral<List<String>[]>() {
    }))));
    assertTrue(TypeUtils.equals(new TypeLiteral<Object[]>() {
    }.value, therianContext.eval(GetElementType.of(new TypeLiteral<Object[][]>() {
    }))));
}

From source file:therian.operator.getelementtype.GetEnumerationElementTypeTest.java

@Test
public void test() {
    assertEquals(String.class, therianContext.eval(GetElementType.of(new TypeLiteral<Enumeration<String>>() {
    })));/*from w ww. j  a v  a2s.  c  om*/
    assertTrue(TypeUtils.equals(new TypeLiteral<List<String>>() {
    }.value, therianContext.eval(GetElementType.of(new TypeLiteral<Enumeration<List<String>>>() {
    }))));
    assertTrue(TypeUtils.equals(new TypeLiteral<String[]>() {
    }.value, therianContext.eval(GetElementType.of(new TypeLiteral<Enumeration<String[]>>() {
    }))));
}

From source file:therian.operator.getelementtype.GetIterableElementTypeTest.java

@Test
public void test() {
    assertEquals(String.class, therianContext.eval(GetElementType.of(new TypeLiteral<Iterable<String>>() {
    })));//from   w  w  w . j a va  2s.c om
    assertEquals(String.class, therianContext.eval(GetElementType.of(new TypeLiteral<List<String>>() {
    })));
    assertEquals(String.class, therianContext.eval(GetElementType.of(new TypeLiteral<Collection<String>>() {
    })));
    assertEquals(String.class, therianContext.eval(GetElementType.of(new TypeLiteral<Set<String>>() {
    })));
    assertEquals(String.class, therianContext.eval(GetElementType.of(new TypeLiteral<SortedSet<String>>() {
    })));
    assertTrue(TypeUtils.equals(new TypeLiteral<String[]>() {
    }.value, therianContext.eval(GetElementType.of(new TypeLiteral<List<String[]>>() {
    }))));
    assertTrue(TypeUtils.equals(new TypeLiteral<Typed<?>>() {
    }.value, therianContext.eval(GetElementType.of(new TypeLiteral<Iterable<Typed<?>>>() {
    }))));
}

From source file:therian.operator.getelementtype.GetIteratorElementTypeTest.java

@Test
public void test() {
    assertEquals(String.class, therianContext.eval(GetElementType.of(new TypeLiteral<Iterator<String>>() {
    })));//from   w  w w.  j av a2s  .c o  m
    assertTrue(TypeUtils.equals(new TypeLiteral<String[]>() {
    }.value, therianContext.eval(GetElementType.of(new TypeLiteral<Iterator<String[]>>() {
    }))));
    assertTrue(TypeUtils.equals(new TypeLiteral<Class<?>>() {
    }.value, therianContext.eval(GetElementType.of(new TypeLiteral<Iterator<Class<?>>>() {
    }))));
}

From source file:therian.operator.getelementtype.GetMapElementTypeTest.java

@Test
public void test() {
    assertEquals(String.class, therianContext.eval(GetElementType.of(new TypeLiteral<Map<String, String>>() {
    })));/*from ww w. j  a v  a  2 s . co m*/
    assertEquals(Object.class, therianContext.eval(GetElementType.of(new TypeLiteral<Map<String, Object>>() {
    })));
    assertTrue(TypeUtils.equals(new TypeLiteral<List<String>>() {
    }.value, therianContext.eval(GetElementType.of(new TypeLiteral<Map<Integer, List<String>>>() {
    }))));
}