Skip to content

Instantly share code, notes, and snippets.

@cshijiel
Created July 13, 2018 10:33
Show Gist options
  • Save cshijiel/a8239473569f52f5d41ff9adc0387f2a to your computer and use it in GitHub Desktop.
Save cshijiel/a8239473569f52f5d41ff9adc0387f2a to your computer and use it in GitHub Desktop.
ParameterNameProvider
private static class ClearParameterNameProvider implements ParameterNameProvider {
private static ParameterNameDiscoverer discoverer = new LocalVariableTableParameterNameDiscoverer();
private static ParameterNameProvider provider = new DefaultParameterNameProvider();
@Override
public List<String> getParameterNames(Constructor<?> constructor) {
String[] parameterNames = discoverer.getParameterNames(constructor);
return Optional.ofNullable(parameterNames).map(Arrays::asList).orElse(provider.getParameterNames(constructor));
}
@Override
public List<String> getParameterNames(Method method) {
String[] parameterNames = discoverer.getParameterNames(method);
return Optional.ofNullable(parameterNames).map(Arrays::asList).orElse(provider.getParameterNames(method));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment