1 | 270 | package com.lexicalscope.fluentreflection; |
2 | |
|
3 | |
import java.lang.reflect.Constructor; |
4 | |
|
5 | |
import ch.lambdaj.function.convert.Converter; |
6 | |
|
7 | |
import com.google.inject.TypeLiteral; |
8 | |
|
9 | |
class ConvertConstructorToReflectedConstructor<T> implements Converter<Constructor<?>, FluentConstructor<T>> { |
10 | |
private final ReflectedTypeFactory reflectedTypeFactory; |
11 | |
private final TypeLiteral<T> typeLiteral; |
12 | |
|
13 | 82 | public ConvertConstructorToReflectedConstructor( |
14 | |
final ReflectedTypeFactory reflectedTypeFactory, |
15 | |
final TypeLiteral<T> typeLiteral) { |
16 | 82 | this.reflectedTypeFactory = reflectedTypeFactory; |
17 | 82 | this.typeLiteral = typeLiteral; |
18 | 82 | } |
19 | |
|
20 | |
public ConvertConstructorToReflectedConstructor( |
21 | |
final ReflectedTypeFactory reflectedTypeFactory, |
22 | |
final Class<T> klass) { |
23 | 8 | this(reflectedTypeFactory, TypeLiteral.get(klass)); |
24 | 8 | } |
25 | |
|
26 | |
@SuppressWarnings("unchecked") @Override public FluentConstructor<T> convert(final Constructor<?> from) { |
27 | 278 | return new FluentConstructorImpl<T>(reflectedTypeFactory, typeLiteral, (Constructor<T>) from); |
28 | |
} |
29 | |
} |