@ -251,31 +251,42 @@ public final class DataSourceBuilder<T extends DataSource> {
* /
* /
private enum DataSourceProperty {
private enum DataSourceProperty {
URL ( "url" ),
URL ( "url" , "URL" ),
DRIVER_CLASS_NAME ( "driverClassName" ) ,
DRIVER_CLASS_NAME ( "driverClassName" ) ,
USERNAME ( "username" ),
USERNAME ( "username" , "user" ),
PASSWORD ( "password" ) ;
PASSWORD ( "password" ) ;
private final String name ;
private final String [ ] name s ;
DataSourceProperty ( String name ) {
DataSourceProperty ( String . . . name s ) {
this . name = name ;
this . name s = name s ;
}
}
@Override
@Override
public String toString ( ) {
public String toString ( ) {
return this . name ;
return this . name s[ 0 ] ;
}
}
Method findSetter ( Class < ? > type ) {
Method findSetter ( Class < ? > type ) {
return ReflectionUtils. findMethod ( type , "set" + StringUtils . capitalize ( this . name ) , String . class ) ;
return extracted( "set" , type ) ;
}
}
Method findGetter ( Class < ? > type ) {
Method findGetter ( Class < ? > type ) {
return ReflectionUtils . findMethod ( type , "get" + StringUtils . capitalize ( this . name ) , String . class ) ;
return extracted ( "get" , type ) ;
}
private Method extracted ( String prefix , Class < ? > type ) {
for ( String candidate : this . names ) {
Method method = ReflectionUtils . findMethod ( type , prefix + StringUtils . capitalize ( candidate ) ,
String . class ) ;
if ( method ! = null ) {
return method ;
}
}
return null ;
}
}
}
}