203203
204204import static org .hibernate .boot .jaxb .hbm .transform .HbmTransformationLogging .TRANSFORMATION_LOGGER ;
205205import static org .hibernate .internal .util .StringHelper .isNotEmpty ;
206+ import static org .hibernate .internal .util .StringHelper .nullIfEmpty ;
206207
207208/**
208209 * Transforms {@code hbm.xml} {@linkplain JaxbHbmHibernateMapping JAXB} bindings into
@@ -1205,7 +1206,7 @@ else if ( !source.getColumnOrFormula().isEmpty() ) {
12051206 }
12061207 }
12071208 }
1208- else if ( StringHelper . isNotEmpty ( tableName ) ) {
1209+ else if ( isNotEmpty ( tableName ) ) {
12091210 // this is the case of transforming a <join/> where the property did not specify columns or formula.
12101211 // we need to create a column still to pass along the secondary table name
12111212 final TargetColumnAdapter column = target .makeColumnAdapter ( columnDefaults );
@@ -1590,7 +1591,7 @@ public Boolean isUpdateable() {
15901591 }
15911592
15921593 private JaxbUserTypeImpl interpretBasicType (String typeName , JaxbHbmConfigParameterContainer typeLocalParams , JaxbHbmTypeDefinitionType typeDef ) {
1593- assert StringHelper . isNotEmpty ( typeName );
1594+ assert isNotEmpty ( typeName );
15941595
15951596 final JaxbUserTypeImpl typeNode = new JaxbUserTypeImpl ();
15961597
@@ -1624,7 +1625,7 @@ private JaxbEmbeddableImpl applyEmbeddable(
16241625 JaxbHbmCompositeAttributeType hbmComponent ,
16251626 ComponentTypeInfo componentTypeInfo ) {
16261627 final String embeddableClassName = componentTypeInfo .getComponent ().getComponentClassName ();
1627- if ( StringHelper . isNotEmpty ( embeddableClassName ) ) {
1628+ if ( isNotEmpty ( embeddableClassName ) ) {
16281629 final JaxbEmbeddableImpl existing = jaxbEmbeddableByClassName .get ( embeddableClassName );
16291630 if ( existing != null ) {
16301631 return existing ;
@@ -1641,7 +1642,7 @@ private JaxbEmbeddableImpl applyEmbeddable(
16411642 );
16421643 mappingXmlBinding .getRoot ().getEmbeddables ().add ( jaxbEmbeddable );
16431644
1644- if ( StringHelper . isNotEmpty ( embeddableClassName ) ) {
1645+ if ( isNotEmpty ( embeddableClassName ) ) {
16451646 jaxbEmbeddableByClassName .put ( embeddableClassName , jaxbEmbeddable );
16461647 }
16471648
@@ -1668,7 +1669,7 @@ private JaxbEmbeddableImpl convertEmbeddable(
16681669
16691670 private int counter = 1 ;
16701671 private String determineEmbeddableName (String componentClassName , String attributeName ) {
1671- if ( StringHelper . isNotEmpty ( componentClassName ) ) {
1672+ if ( isNotEmpty ( componentClassName ) ) {
16721673 return componentClassName ;
16731674 }
16741675 return attributeName + "_" + counter ++;
@@ -1692,7 +1693,7 @@ private void transferOneToOne(JaxbHbmOneToOneType hbmOneToOne, PropertyInfo prop
16921693 oneToOne .setOrphanRemoval ( isOrphanRemoval ( hbmOneToOne .getCascade () ) );
16931694 oneToOne .setForeignKey ( new JaxbForeignKeyImpl () );
16941695 oneToOne .getForeignKey ().setName ( hbmOneToOne .getForeignKey () );
1695- if ( StringHelper . isNotEmpty ( hbmOneToOne .getPropertyRef () ) ) {
1696+ if ( isNotEmpty ( hbmOneToOne .getPropertyRef () ) ) {
16961697 oneToOne .setPropertyRef ( new JaxbPropertyRefImpl () );
16971698 oneToOne .getPropertyRef ().setName ( hbmOneToOne .getPropertyRef () );
16981699 }
@@ -1736,7 +1737,7 @@ private JaxbManyToOneImpl transformManyToOne(JaxbHbmManyToOneType hbmNode, Prope
17361737 jaxbManyToOne .setAttributeAccessor ( hbmNode .getAccess () );
17371738 jaxbManyToOne .setCascade ( convertCascadeType ( hbmNode .getCascade () ) );
17381739
1739- if ( StringHelper . isNotEmpty ( hbmNode .getPropertyRef () ) ) {
1740+ if ( isNotEmpty ( hbmNode .getPropertyRef () ) ) {
17401741 jaxbManyToOne .setPropertyRef ( new JaxbPropertyRefImpl () );
17411742 jaxbManyToOne .getPropertyRef ().setName ( hbmNode .getPropertyRef () );
17421743 }
@@ -1905,23 +1906,23 @@ private void transferCollectionCommonInfo(PluralAttributeInfo source, JaxbPlural
19051906 target .setFetchMode ( convert ( source .getFetch () ) );
19061907 target .setFetch ( convert ( source .getLazy () ) );
19071908
1908- if ( StringHelper . isNotEmpty ( source .getCollectionType () ) ) {
1909+ if ( isNotEmpty ( source .getCollectionType () ) ) {
19091910 final JaxbCollectionUserTypeImpl jaxbCollectionUserType = new JaxbCollectionUserTypeImpl ();
19101911 target .setCollectionType ( jaxbCollectionUserType );
19111912 jaxbCollectionUserType .setType ( source .getCollectionType () );
19121913 }
19131914
19141915 if ( source instanceof JaxbHbmSetType set ) {
19151916 final String sort = set .getSort ();
1916- if ( StringHelper . isNotEmpty ( sort ) && !"unsorted" .equals ( sort ) ) {
1917+ if ( isNotEmpty ( sort ) && !"unsorted" .equals ( sort ) ) {
19171918 target .setSort ( sort );
19181919 }
19191920 target .setOrderBy ( set .getOrderBy () );
19201921 target .setClassification ( LimitedCollectionClassification .SET );
19211922 }
19221923 else if ( source instanceof JaxbHbmMapType map ) {
19231924 final String sort = map .getSort ();
1924- if ( StringHelper . isNotEmpty ( sort ) && !"unsorted" .equals ( sort ) ) {
1925+ if ( isNotEmpty ( sort ) && !"unsorted" .equals ( sort ) ) {
19251926 target .setSort ( sort );
19261927 }
19271928 target .setOrderBy ( map .getOrderBy () );
@@ -2025,7 +2026,7 @@ else if ( source.getMapKey() != null ) {
20252026 return ;
20262027 }
20272028
2028- if ( StringHelper . isNotEmpty ( source .getMapKey ().getNode () ) ) {
2029+ if ( isNotEmpty ( source .getMapKey ().getNode () ) ) {
20292030 handleUnsupported (
20302031 "Transformation of `node` attribute is not supported - %s" ,
20312032 origin ()
@@ -2040,7 +2041,7 @@ else if ( source.getMapKey() != null ) {
20402041 jaxbMapKeyType .setValue ( mapKeyType );
20412042 }
20422043
2043- if ( StringHelper . isNotEmpty ( source .getMapKey ().getColumnAttribute () ) ) {
2044+ if ( isNotEmpty ( source .getMapKey ().getColumnAttribute () ) ) {
20442045 final JaxbMapKeyColumnImpl mapKeyColumn = new JaxbMapKeyColumnImpl ();
20452046 mapKeyColumn .setName ( source .getMapKey ().getColumnAttribute () );
20462047 target .setMapKeyColumn ( mapKeyColumn );
@@ -2049,38 +2050,32 @@ else if ( source.getMapKey() != null ) {
20492050 }
20502051
20512052 private String resolveMapKeyType (JaxbHbmMapKeyBasicType mapKey ) {
2052- if ( StringHelper . isNotEmpty ( mapKey .getTypeAttribute () ) ) {
2053+ if ( isNotEmpty ( mapKey .getTypeAttribute () ) ) {
20532054 return mapKey .getTypeAttribute ();
20542055 }
2055-
2056- if ( mapKey .getType () != null ) {
2057- return StringHelper .nullIfEmpty ( mapKey .getType ().getName () );
2056+ else if ( mapKey .getType () != null ) {
2057+ return nullIfEmpty ( mapKey .getType ().getName () );
2058+ }
2059+ else {
2060+ return null ;
20582061 }
2059-
2060- return null ;
20612062 }
20622063
20632064 private Boolean invert (Boolean value ) {
2064- return invert ( value , null );
2065- }
2066-
2067- private Boolean invert (Boolean value , Boolean defaultValue ) {
2068- if ( value == null ) {
2069- return defaultValue ;
2070- }
2071- return !value ;
2065+ return value == null ? null : !value ;
20722066 }
20732067
20742068 private JaxbPluralFetchModeImpl convert (JaxbHbmFetchStyleWithSubselectEnum fetch ) {
2075- if ( fetch != null ) {
2069+ if ( fetch == null ) {
2070+ return null ;
2071+ }
2072+ else {
20762073 return switch ( fetch ) {
20772074 case SELECT -> JaxbPluralFetchModeImpl .SELECT ;
20782075 case JOIN -> JaxbPluralFetchModeImpl .JOIN ;
20792076 case SUBSELECT -> JaxbPluralFetchModeImpl .SUBSELECT ;
20802077 };
20812078 }
2082-
2083- return null ;
20842079 }
20852080
20862081
@@ -2181,7 +2176,7 @@ private void transferElementInfo(
21812176 final ComponentTypeInfo componentTypeInfo = transformationState .getEmbeddableInfoByRole ().get ( partRole );
21822177
21832178 target .setTarget ( embeddableName );
2184- if ( StringHelper . isNotEmpty ( embeddableClassName ) ) {
2179+ if ( isNotEmpty ( embeddableClassName ) ) {
21852180 target .setTargetClass ( embeddableClassName );
21862181 }
21872182
@@ -2217,7 +2212,7 @@ private void transferOneToManyInfo(
22172212 }
22182213
22192214 transferCollectionCommonInfo ( hbmAttributeInfo , target );
2220- target .setTargetEntity ( StringHelper . isNotEmpty ( hbmOneToMany .getClazz () ) ? hbmOneToMany .getClazz () : hbmOneToMany .getEntityName () );
2215+ target .setTargetEntity ( isNotEmpty ( hbmOneToMany .getClazz () ) ? hbmOneToMany .getClazz () : hbmOneToMany .getEntityName () );
22212216
22222217 final Property bootModelProperty = propertyInfo .bootModelProperty ();
22232218 final Collection bootModelValue = (Collection ) bootModelProperty .getValue ();
@@ -2291,7 +2286,7 @@ public void addFormula(String formula) {
22912286 target .getFilters ().add ( convert ( hbmFilter ) );
22922287 }
22932288
2294- if ( StringHelper . isNotEmpty ( hbmAttributeInfo .getWhere () ) ) {
2289+ if ( isNotEmpty ( hbmAttributeInfo .getWhere () ) ) {
22952290 target .setSqlRestriction ( hbmAttributeInfo .getWhere () );
22962291 }
22972292 if ( hbmAttributeInfo .getSqlInsert () != null ) {
@@ -2320,7 +2315,7 @@ private String resolveMappedBy(
23202315 PluralAttributeInfo hbmAttributeInfo ,
23212316 Property bootModelProperty ,
23222317 Collection bootModelValue ) {
2323- if ( StringHelper . isNotEmpty ( bootModelValue .getMappedByProperty () ) ) {
2318+ if ( isNotEmpty ( bootModelValue .getMappedByProperty () ) ) {
23242319 return bootModelValue .getMappedByProperty ();
23252320 }
23262321
@@ -2369,8 +2364,8 @@ private boolean matches(KeyValue collectionKey, List<Selectable> candidate) {
23692364
23702365 final Column collectionKeyColumn = (Column ) collectionKeySelectable ;
23712366 final Column candidateColumn = (Column ) candidateSelectable ;
2372- assert StringHelper . isNotEmpty ( collectionKeyColumn .getCanonicalName () );
2373- assert StringHelper . isNotEmpty ( candidateColumn .getCanonicalName () );
2367+ assert isNotEmpty ( collectionKeyColumn .getCanonicalName () );
2368+ assert isNotEmpty ( candidateColumn .getCanonicalName () );
23742369 if ( !collectionKeyColumn .getCanonicalName ().equals ( candidateColumn .getCanonicalName () ) ) {
23752370 return false ;
23762371 }
@@ -2400,7 +2395,7 @@ private void transferManyToManyInfo(
24002395 if ( manyToMany .isEmbedXml () != null ) {
24012396 handleUnsupported ( "`embed-xml` no longer supported" );
24022397 }
2403- if ( StringHelper . isNotEmpty ( manyToMany .getNode () ) ) {
2398+ if ( isNotEmpty ( manyToMany .getNode () ) ) {
24042399 handleUnsupported ( "`node` no longer supported" );
24052400 }
24062401
@@ -2409,7 +2404,7 @@ private void transferManyToManyInfo(
24092404
24102405 final JaxbJoinTableImpl joinTable = new JaxbJoinTableImpl ();
24112406 final String tableName = hbmCollection .getTable ();
2412- if ( StringHelper . isNotEmpty ( tableName ) ) {
2407+ if ( isNotEmpty ( tableName ) ) {
24132408 joinTable .setName ( tableName );
24142409 }
24152410 target .setJoinTable ( joinTable );
@@ -2503,7 +2498,7 @@ public void addFormula(String formula) {
25032498 );
25042499
25052500 transferCollectionCommonInfo ( hbmCollection , target );
2506- target .setTargetEntity ( StringHelper . isNotEmpty ( manyToMany .getClazz () ) ? manyToMany .getClazz () : manyToMany .getEntityName () );
2501+ target .setTargetEntity ( isNotEmpty ( manyToMany .getClazz () ) ? manyToMany .getClazz () : manyToMany .getEntityName () );
25072502
25082503 if ( manyToMany .getNotFound () == JaxbHbmNotFoundEnum .IGNORE ) {
25092504 target .setNotFound ( NotFoundAction .IGNORE );
@@ -2513,7 +2508,7 @@ public void addFormula(String formula) {
25132508 target .getFilters ().add ( convert ( hbmFilter ) );
25142509 }
25152510
2516- if ( StringHelper . isNotEmpty ( hbmCollection .getWhere () ) ) {
2511+ if ( isNotEmpty ( hbmCollection .getWhere () ) ) {
25172512 target .setSqlRestriction ( hbmCollection .getWhere () );
25182513 }
25192514 if ( hbmCollection .getSqlInsert () != null ) {
@@ -2664,7 +2659,7 @@ private JaxbEmbeddableImpl transformEmbeddedIdEmbeddable(
26642659 EntityTypeInfo bootEntityInfo ,
26652660 Property idProperty ) {
26662661 final String embeddableClassName = hbmCompositeId .getClazz ();
2667- if ( StringHelper . isNotEmpty ( embeddableClassName ) ) {
2662+ if ( isNotEmpty ( embeddableClassName ) ) {
26682663 final JaxbEmbeddableImpl existing = jaxbEmbeddableByClassName .get ( embeddableClassName );
26692664 if ( existing != null ) {
26702665 return existing ;
0 commit comments