Search in sources :

Example 1 with ConstructorNotFoundException

use of org.simpleflatmapper.reflect.ConstructorNotFoundException in project SimpleFlatMapper by arnaudroger.

the class TupleClassMetaTest method failOnNoConstructorMatchingType.

@Test
public void failOnNoConstructorMatchingType() {
    Type type = new TypeReference<MyTuple<String, String>>() {
    }.getType();
    try {
        new TupleClassMeta<MyTuple<String, String>>(type, ReflectionService.newInstance());
        fail();
    } catch (ConstructorNotFoundException e) {
    // expect
    }
}
Also used : Type(java.lang.reflect.Type) ConstructorNotFoundException(org.simpleflatmapper.reflect.ConstructorNotFoundException) Test(org.junit.Test)

Example 2 with ConstructorNotFoundException

use of org.simpleflatmapper.reflect.ConstructorNotFoundException in project SimpleFlatMapper by arnaudroger.

the class TupleClassMeta method getInstantiatorDefinition.

private InstantiatorDefinition getInstantiatorDefinition(Type type, ReflectionService reflectionService) throws java.io.IOException {
    final List<InstantiatorDefinition> definitions = reflectionService.extractInstantiator(type);
    ListIterator<InstantiatorDefinition> iterator = definitions.listIterator();
    while (iterator.hasNext()) {
        final InstantiatorDefinition definition = iterator.next();
        if (isTupleConstructor(type, definition)) {
            return respecifyParameterNames((ExecutableInstantiatorDefinition) definition);
        }
    }
    throw new ConstructorNotFoundException("Cannot find eligible tuple constructor definition for " + type);
}
Also used : ExecutableInstantiatorDefinition(org.simpleflatmapper.reflect.instantiator.ExecutableInstantiatorDefinition) InstantiatorDefinition(org.simpleflatmapper.reflect.InstantiatorDefinition) ConstructorNotFoundException(org.simpleflatmapper.reflect.ConstructorNotFoundException)

Aggregations

ConstructorNotFoundException (org.simpleflatmapper.reflect.ConstructorNotFoundException)2 Type (java.lang.reflect.Type)1 Test (org.junit.Test)1 InstantiatorDefinition (org.simpleflatmapper.reflect.InstantiatorDefinition)1 ExecutableInstantiatorDefinition (org.simpleflatmapper.reflect.instantiator.ExecutableInstantiatorDefinition)1