Having a generic static function where I just have the generic types, it´s possible to get the Class of one of those generics?
Here my code:
public static <A extends ResultError, B, A1 extends ResultError, B1> Function1<Either<A, B>,
Either<A1, B1>> transformConnectorErrorVoToCommandError(Event event) {
return new AbstractFunction1<Either<A, B>, Either<A1, B1>>() {
@Override
public Either<A1, B1> apply(Either<A, B> parameter) {
if (parameter.isRight()) {
return mapsRightSide(parameter);
} else {
return mapsLeftSide(parameter, event, ${I NEED THE CLASS OF A HERE});
}
}
Either<A1, B1> mapsRightSide(Either<A, B> parameter) {
return right(parameter.right().get());
}
Right right(Object result) {
return new Right<>(result);
}
};
}
private static <A extends ResultError, B, A1 extends ResultError, B1> Either<A1, B1> mapsLeftSide(Either<A, B> parameter,
Event event,
Class<A1> outputErrorClass) {
initLazyMapperComponent();
A sourceError = parameter.left().get();
A1 destinyError = mapper.map(sourceError, outputErrorClass);
if (destinyError != null) {
return left(destinyError);
}
ExceptionUtil.throwNotHandledError(event, sourceError);
return null;
}
the part that I need in the code is ${I NEED THE CLASS OF A HERE}
I know that in a non static function it´s possible but not idea if can be done in a static way.
Regards.