@@ -41,27 +41,31 @@ class PersistentEntityIsNewStrategy implements IsNewStrategy {
4141 * Creates a new {@link PersistentEntityIsNewStrategy} for the given entity.
4242 *
4343 * @param entity must not be {@literal null}.
44+ * @param idOnly {@code true} if should consider only the ID property of the {@link PersistentEntity}, {@code false}
45+ * if other properties such as {@link PersistentEntity#getVersionProperty() version} shall be
46+ * considered.
4447 */
4548 private PersistentEntityIsNewStrategy (PersistentEntity <?, ?> entity , boolean idOnly ) {
4649
4750 Assert .notNull (entity , "PersistentEntity must not be null" );
4851
49- this . valueLookup = entity .hasVersionProperty () && !idOnly //
50- ? source -> entity .getPropertyAccessor (source ).getProperty (entity .getRequiredVersionProperty ())
51- : source -> entity .getIdentifierAccessor ( source ). getIdentifier ();
52-
53- this .valueType = entity .hasVersionProperty () && ! idOnly //
54- ? entity .getRequiredVersionProperty ().getType () //
55- : entity . hasIdProperty () ? entity . getRequiredIdProperty (). getType () : null ;
52+ if ( entity .hasVersionProperty () && !idOnly ) {
53+ this . valueLookup = source -> entity .getPropertyAccessor (source ).getProperty (entity .getRequiredVersionProperty ());
54+ this . valueType = entity .getRequiredVersionProperty (). getType ();
55+ } else {
56+ this .valueLookup = source -> entity .getIdentifierAccessor ( source ). getIdentifier ();
57+ this . valueType = entity . hasIdProperty () ? entity .getRequiredIdProperty ().getType () : null ;
58+ }
5659
5760 Class <?> type = valueType ;
5861
5962 if (type != null && type .isPrimitive ()) {
6063
6164 if (!ClassUtils .isAssignable (Number .class , type )) {
6265
63- throw new IllegalArgumentException (String
64- .format ("Only numeric primitives are supported as identifier / version field types; Got: %s" , valueType ));
66+ throw new IllegalArgumentException (
67+ String .format ("Only numeric primitives are supported as identifier / version field types; Got: %s" ,
68+ valueType ));
6569 }
6670 }
6771 }
0 commit comments