HHH-7098 - Have JandexHelper handle "undefined" values as null
This commit is contained in:
parent
315b06ebda
commit
b6902ad211
|
@ -335,7 +335,7 @@ public class JandexHelper {
|
||||||
if ( defaultValue.getClass().isArray() && defaultValue.getClass().getComponentType().isAnnotation() ) {
|
if ( defaultValue.getClass().isArray() && defaultValue.getClass().getComponentType().isAnnotation() ) {
|
||||||
returnValue = new AnnotationInstance[0];
|
returnValue = new AnnotationInstance[0];
|
||||||
}
|
}
|
||||||
return type.cast( returnValue );
|
return type.cast( nullIfUndefined( returnValue, type ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
private static <T> T explicitAnnotationParameter(AnnotationValue annotationValue, Class<T> type) {
|
private static <T> T explicitAnnotationParameter(AnnotationValue annotationValue, Class<T> type) {
|
||||||
|
@ -358,6 +358,30 @@ public class JandexHelper {
|
||||||
returnValue = arr;
|
returnValue = arr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return type.cast( returnValue );
|
return type.cast( nullIfUndefined( returnValue, type ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Swaps type-specific undefined values with {@code null}.
|
||||||
|
*
|
||||||
|
* @param value The value
|
||||||
|
* @param type The target type
|
||||||
|
*
|
||||||
|
* @return {@code null} if value is deemed to UNDEFINED; value itself otherwise.
|
||||||
|
*/
|
||||||
|
private static Object nullIfUndefined(Object value, Class type) {
|
||||||
|
if ( value instanceof Type ) {
|
||||||
|
value = ( (Type) value ).name().toString();
|
||||||
|
if ( void.class.getName().equals( value ) ) {
|
||||||
|
value = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( String.class.equals( type ) ) {
|
||||||
|
if ( "".equals( type.cast( value ) ) ) {
|
||||||
|
value = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,8 +33,7 @@ class TableSourceImpl implements TableSource {
|
||||||
TableSourceImpl(String schema, String catalog, String tableName) {
|
TableSourceImpl(String schema, String catalog, String tableName) {
|
||||||
this.schema = schema;
|
this.schema = schema;
|
||||||
this.catalog = catalog;
|
this.catalog = catalog;
|
||||||
// for some reason annotations passing in "" sometimes :(
|
this.tableName = tableName;
|
||||||
this.tableName = "".equals( tableName ) ? null : tableName;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue