175
175
import static org .hibernate .boot .models .JpaAnnotations .UNIQUE_CONSTRAINT ;
176
176
import static org .hibernate .boot .models .xml .internal .UserTypeCasesMapKey .MAP_KEY_USER_TYPE_CASES ;
177
177
import static org .hibernate .boot .models .xml .internal .UserTypeCasesStandard .STANDARD_USER_TYPE_CASES ;
178
+ import static org .hibernate .internal .util .StringHelper .isEmpty ;
179
+ import static org .hibernate .internal .util .StringHelper .isNotEmpty ;
180
+ import static org .hibernate .internal .util .StringHelper .unqualify ;
178
181
179
182
/**
180
183
* Helper for creating annotation from equivalent JAXB
@@ -194,7 +197,7 @@ public static void applyEntity(
194
197
JpaAnnotations .ENTITY ,
195
198
xmlDocumentContext .getModelBuildingContext ()
196
199
);
197
- if ( StringHelper . isNotEmpty ( jaxbEntity .getName () ) ) {
200
+ if ( isNotEmpty ( jaxbEntity .getName () ) ) {
198
201
entityAnn .name ( jaxbEntity .getName () );
199
202
}
200
203
}
@@ -227,8 +230,8 @@ public static void applyColumnTransformation(
227
230
JaxbColumnImpl jaxbColumn ,
228
231
MutableMemberDetails memberDetails ,
229
232
XmlDocumentContext xmlDocumentContext ) {
230
- if ( StringHelper . isEmpty ( jaxbColumn .getRead () )
231
- && StringHelper . isEmpty ( jaxbColumn .getWrite () ) ) {
233
+ if ( isEmpty ( jaxbColumn .getRead () )
234
+ && isEmpty ( jaxbColumn .getWrite () ) ) {
232
235
return ;
233
236
}
234
237
@@ -239,10 +242,10 @@ public static void applyColumnTransformation(
239
242
240
243
annotationUsage .forColumn ( jaxbColumn .getName () );
241
244
242
- if ( StringHelper . isNotEmpty ( jaxbColumn .getRead () ) ) {
245
+ if ( isNotEmpty ( jaxbColumn .getRead () ) ) {
243
246
annotationUsage .read ( jaxbColumn .getRead () );
244
247
}
245
- if ( StringHelper . isNotEmpty ( jaxbColumn .getWrite () ) ) {
248
+ if ( isNotEmpty ( jaxbColumn .getWrite () ) ) {
246
249
annotationUsage .write ( jaxbColumn .getWrite () );
247
250
}
248
251
}
@@ -266,7 +269,7 @@ public static void applyUserType(
266
269
MutableMemberDetails memberDetails ,
267
270
UserTypeCases cases ,
268
271
XmlDocumentContext xmlDocumentContext ) {
269
- if ( jaxbType == null || StringHelper . isEmpty ( jaxbType .getValue () ) ) {
272
+ if ( jaxbType == null || isEmpty ( jaxbType .getValue () ) ) {
270
273
cases .handleNone ( jaxbType , memberDetails , xmlDocumentContext );
271
274
return ;
272
275
}
@@ -383,7 +386,7 @@ public static void applyCollectionId(
383
386
}
384
387
385
388
final JaxbGeneratedValueImpl generator = jaxbCollectionId .getGenerator ();
386
- if ( generator != null && StringHelper . isNotEmpty ( generator .getGenerator () ) ) {
389
+ if ( generator != null && isNotEmpty ( generator .getGenerator () ) ) {
387
390
collectionIdAnn .generator ( generator .getGenerator () );
388
391
}
389
392
}
@@ -510,7 +513,7 @@ public static void applyGeneratedValue(
510
513
generatedValueAnn .strategy ( jaxbGeneratedValue .getStrategy () );
511
514
}
512
515
513
- if ( StringHelper . isNotEmpty ( jaxbGeneratedValue .getGenerator () ) ) {
516
+ if ( isNotEmpty ( jaxbGeneratedValue .getGenerator () ) ) {
514
517
generatedValueAnn .generator ( jaxbGeneratedValue .getGenerator () );
515
518
}
516
519
}
@@ -528,19 +531,19 @@ public static void applySequenceGenerator(
528
531
xmlDocumentContext .getModelBuildingContext ()
529
532
);
530
533
531
- if ( StringHelper . isNotEmpty ( jaxbGenerator .getName () ) ) {
534
+ if ( isNotEmpty ( jaxbGenerator .getName () ) ) {
532
535
sequenceAnn .name ( jaxbGenerator .getName () );
533
536
}
534
537
535
538
if ( jaxbGenerator .getSequenceName () != null ) {
536
539
sequenceAnn .sequenceName ( jaxbGenerator .getSequenceName () );
537
540
}
538
541
539
- if ( StringHelper . isNotEmpty ( jaxbGenerator .getCatalog () ) ) {
542
+ if ( isNotEmpty ( jaxbGenerator .getCatalog () ) ) {
540
543
sequenceAnn .catalog ( jaxbGenerator .getCatalog () );
541
544
}
542
545
543
- if ( StringHelper . isNotEmpty ( jaxbGenerator .getSchema () ) ) {
546
+ if ( isNotEmpty ( jaxbGenerator .getSchema () ) ) {
544
547
sequenceAnn .schema ( jaxbGenerator .getSchema () );
545
548
}
546
549
@@ -552,7 +555,7 @@ public static void applySequenceGenerator(
552
555
sequenceAnn .allocationSize ( jaxbGenerator .getAllocationSize () );
553
556
}
554
557
555
- if ( StringHelper . isNotEmpty ( jaxbGenerator .getOptions () ) ) {
558
+ if ( isNotEmpty ( jaxbGenerator .getOptions () ) ) {
556
559
sequenceAnn .options ( jaxbGenerator .getOptions () );
557
560
}
558
561
}
@@ -839,10 +842,10 @@ private static void transferConvertDetails(
839
842
ConvertJpaAnnotation convert ,
840
843
String namePrefix ,
841
844
XmlDocumentContext xmlDocumentContext ) {
842
- if ( StringHelper . isNotEmpty ( jaxbConvert .getConverter () ) ) {
845
+ if ( isNotEmpty ( jaxbConvert .getConverter () ) ) {
843
846
convert .converter ( xmlDocumentContext .resolveJavaType ( jaxbConvert .getConverter () ).toJavaClass () );
844
847
}
845
- if ( StringHelper . isNotEmpty ( jaxbConvert .getAttributeName () ) ) {
848
+ if ( isNotEmpty ( jaxbConvert .getAttributeName () ) ) {
846
849
convert .attributeName ( prefixIfNotAlready ( jaxbConvert .getAttributeName (), namePrefix ) );
847
850
}
848
851
if ( jaxbConvert .isDisableConversion () != null ) {
@@ -858,16 +861,16 @@ public static void applyTable(
858
861
final XmlDocument .Defaults defaults = xmlDocumentContext .getXmlDocument ().getDefaults ();
859
862
final String catalog = defaults .getCatalog ();
860
863
final String schema = defaults .getSchema ();
861
- if ( StringHelper . isNotEmpty ( catalog ) || StringHelper . isNotEmpty ( schema ) ) {
864
+ if ( isNotEmpty ( catalog ) || isNotEmpty ( schema ) ) {
862
865
final TableJpaAnnotation tableAnn = (TableJpaAnnotation ) target .applyAnnotationUsage (
863
866
JpaAnnotations .TABLE ,
864
867
xmlDocumentContext .getModelBuildingContext ()
865
868
);
866
- if ( StringHelper . isNotEmpty ( catalog ) ) {
869
+ if ( isNotEmpty ( catalog ) ) {
867
870
tableAnn .catalog ( catalog );
868
871
869
872
}
870
- if ( StringHelper . isNotEmpty ( schema ) ) {
873
+ if ( isNotEmpty ( schema ) ) {
871
874
tableAnn .schema ( schema );
872
875
}
873
876
}
@@ -882,7 +885,7 @@ public static void applyTable(
882
885
}
883
886
884
887
public static void applyOptionalString (String value , Consumer <String > target ) {
885
- if ( StringHelper . isNotEmpty ( value ) ) {
888
+ if ( isNotEmpty ( value ) ) {
886
889
target .accept ( value );
887
890
}
888
891
}
@@ -901,7 +904,7 @@ public static void applyNaturalIdCache(
901
904
);
902
905
903
906
final JaxbCachingImpl jaxbCaching = jaxbNaturalId .getCaching ();
904
- if ( StringHelper . isNotEmpty ( jaxbCaching .getRegion () ) ) {
907
+ if ( isNotEmpty ( jaxbCaching .getRegion () ) ) {
905
908
naturalIdCacheUsage .region ( jaxbCaching .getRegion () );
906
909
}
907
910
}
@@ -948,7 +951,7 @@ public static ClassDetails resolveJavaType(String value, ClassDetailsRegistry cl
948
951
}
949
952
950
953
public static ClassDetails resolveJavaType (String packageName , String name , ClassDetailsRegistry classDetailsRegistry ) {
951
- if ( StringHelper . isEmpty ( name ) ) {
954
+ if ( isEmpty ( name ) ) {
952
955
name = Object .class .getName ();
953
956
}
954
957
else if ( byte .class .getName ().equals ( name )
@@ -1013,17 +1016,17 @@ public static void applyBasicTypeComposition(
1013
1016
else if ( jaxbBasicMapping .getJavaType () != null ) {
1014
1017
applyJavaTypeDescriptor ( jaxbBasicMapping .getJavaType (), memberDetails , xmlDocumentContext );
1015
1018
}
1016
- else if ( StringHelper . isNotEmpty ( jaxbBasicMapping .getTarget () ) ) {
1019
+ else if ( isNotEmpty ( jaxbBasicMapping .getTarget () ) ) {
1017
1020
applyTargetClass ( jaxbBasicMapping .getTarget (), memberDetails , xmlDocumentContext );
1018
1021
}
1019
1022
1020
- if ( StringHelper . isNotEmpty ( jaxbBasicMapping .getJdbcType () ) ) {
1023
+ if ( isNotEmpty ( jaxbBasicMapping .getJdbcType () ) ) {
1021
1024
applyJdbcTypeDescriptor ( jaxbBasicMapping .getJdbcType (), memberDetails , xmlDocumentContext );
1022
1025
}
1023
1026
else if ( jaxbBasicMapping .getJdbcTypeCode () != null ) {
1024
1027
applyJdbcTypeCode ( jaxbBasicMapping .getJdbcTypeCode (), memberDetails , xmlDocumentContext );
1025
1028
}
1026
- else if ( StringHelper . isNotEmpty ( jaxbBasicMapping .getJdbcTypeName () ) ) {
1029
+ else if ( isNotEmpty ( jaxbBasicMapping .getJdbcTypeName () ) ) {
1027
1030
applyJdbcTypeCode (
1028
1031
resolveJdbcTypeName ( jaxbBasicMapping .getJdbcTypeName () ),
1029
1032
memberDetails ,
@@ -1143,7 +1146,7 @@ public static void applySqlRestriction(
1143
1146
String sqlRestriction ,
1144
1147
MutableAnnotationTarget target ,
1145
1148
XmlDocumentContext xmlDocumentContext ) {
1146
- if ( StringHelper . isEmpty ( sqlRestriction ) ) {
1149
+ if ( isEmpty ( sqlRestriction ) ) {
1147
1150
return ;
1148
1151
}
1149
1152
@@ -1158,7 +1161,7 @@ public static void applySqlJoinTableRestriction(
1158
1161
String sqlRestriction ,
1159
1162
MutableAnnotationTarget target ,
1160
1163
XmlDocumentContext xmlDocumentContext ) {
1161
- if ( StringHelper . isEmpty ( sqlRestriction ) ) {
1164
+ if ( isEmpty ( sqlRestriction ) ) {
1162
1165
return ;
1163
1166
}
1164
1167
final SQLJoinTableRestrictionAnnotation sqlRestrictionAnn = (SQLJoinTableRestrictionAnnotation ) target .applyAnnotationUsage (
@@ -1195,7 +1198,7 @@ public static void applyCustomSql(
1195
1198
annotation .sql ( jaxbCustomSql .getValue () );
1196
1199
annotation .callable ( jaxbCustomSql .isCallable () );
1197
1200
1198
- if ( StringHelper . isNotEmpty ( jaxbCustomSql .getTable () ) ) {
1201
+ if ( isNotEmpty ( jaxbCustomSql .getTable () ) ) {
1199
1202
annotation .table ( jaxbCustomSql .getTable () );
1200
1203
}
1201
1204
@@ -1217,7 +1220,7 @@ static void applyIdClass(
1217
1220
JaxbIdClassImpl jaxbIdClass ,
1218
1221
MutableClassDetails target ,
1219
1222
XmlDocumentContext xmlDocumentContext ) {
1220
- if ( jaxbIdClass == null || StringHelper . isEmpty ( jaxbIdClass .getClazz () ) ) {
1223
+ if ( jaxbIdClass == null || isEmpty ( jaxbIdClass .getClazz () ) ) {
1221
1224
return ;
1222
1225
}
1223
1226
@@ -1325,7 +1328,8 @@ private static MutableMemberDetails getCallbackMethodDetails(
1325
1328
JpaEventListenerStyle callbackType ,
1326
1329
ClassDetails classDetails ) {
1327
1330
for ( MethodDetails method : classDetails .getMethods () ) {
1328
- if ( method .getName ().equals ( name ) && JpaEventListener .matchesSignature ( callbackType , method ) ) {
1331
+ if ( method .getName ().equals ( name )
1332
+ && JpaEventListener .matchesSignature ( callbackType , method ) ) {
1329
1333
return (MutableMemberDetails ) method ;
1330
1334
}
1331
1335
}
@@ -1344,14 +1348,14 @@ static void applyRowId(
1344
1348
HibernateAnnotations .ROW_ID ,
1345
1349
xmlDocumentContext .getModelBuildingContext ()
1346
1350
);
1347
- if ( StringHelper . isNotEmpty ( rowId ) ) {
1351
+ if ( isNotEmpty ( rowId ) ) {
1348
1352
rowIdAnn .value ( rowId );
1349
1353
}
1350
1354
}
1351
1355
1352
1356
private static String prefixIfNotAlready (String value , String prefix ) {
1353
- if ( StringHelper . isNotEmpty ( prefix ) ) {
1354
- final String previous = StringHelper . unqualify ( value );
1357
+ if ( isNotEmpty ( prefix ) ) {
1358
+ final String previous = unqualify ( value );
1355
1359
if ( !previous .equalsIgnoreCase ( prefix ) ) {
1356
1360
return StringHelper .qualify ( prefix , value );
1357
1361
}
@@ -1363,7 +1367,7 @@ static void applyDiscriminatorValue(
1363
1367
String discriminatorValue ,
1364
1368
MutableClassDetails target ,
1365
1369
XmlDocumentContext xmlDocumentContext ) {
1366
- if ( StringHelper . isEmpty ( discriminatorValue ) ) {
1370
+ if ( isEmpty ( discriminatorValue ) ) {
1367
1371
return ;
1368
1372
}
1369
1373
@@ -1408,7 +1412,7 @@ public static void applyDiscriminatorFormula(
1408
1412
if ( jaxbDiscriminatorFormula == null ) {
1409
1413
return ;
1410
1414
}
1411
- if ( StringHelper . isEmpty ( jaxbDiscriminatorFormula .getFragment () ) ) {
1415
+ if ( isEmpty ( jaxbDiscriminatorFormula .getFragment () ) ) {
1412
1416
return ;
1413
1417
}
1414
1418
@@ -1464,10 +1468,10 @@ public static void applySchema(
1464
1468
return ;
1465
1469
}
1466
1470
1467
- if ( StringHelper . isNotEmpty ( jaxbNode .getSchema () ) ) {
1471
+ if ( isNotEmpty ( jaxbNode .getSchema () ) ) {
1468
1472
annotationUsage .schema ( jaxbNode .getSchema () );
1469
1473
}
1470
- else if ( StringHelper . isNotEmpty ( documentSchema ( xmlDocumentContext ) ) ) {
1474
+ else if ( isNotEmpty ( documentSchema ( xmlDocumentContext ) ) ) {
1471
1475
annotationUsage .schema ( documentSchema ( xmlDocumentContext ) );
1472
1476
}
1473
1477
}
@@ -1500,10 +1504,10 @@ public static void applyCatalog(
1500
1504
return ;
1501
1505
}
1502
1506
1503
- if ( StringHelper . isNotEmpty ( jaxbNode .getCatalog () ) ) {
1507
+ if ( isNotEmpty ( jaxbNode .getCatalog () ) ) {
1504
1508
annotationUsage .catalog ( jaxbNode .getCatalog () );
1505
1509
}
1506
- else if ( StringHelper . isNotEmpty ( documentCatalog ( xmlDocumentContext ) ) ) {
1510
+ else if ( isNotEmpty ( documentCatalog ( xmlDocumentContext ) ) ) {
1507
1511
annotationUsage .catalog ( documentCatalog ( xmlDocumentContext ) );
1508
1512
}
1509
1513
}
0 commit comments