Skip to content

Commit

Permalink
HHH-15634 Extracting constant for @transient annotation in ByteBuddy …
Browse files Browse the repository at this point in the history
…Enhancer
  • Loading branch information
Sanne committed Nov 3, 2022
1 parent dd7cbe8 commit e7fe516
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
public class EnhancerImpl implements Enhancer {

private static final CoreMessageLogger log = CoreLogging.messageLogger( Enhancer.class );
private static final AnnotationDescription TRANSIENT_ANNOTATION = AnnotationDescription.Builder.ofType( Transient.class ).build();

protected final ByteBuddyEnhancementContext enhancementContext;
private final ByteBuddyState byteBuddyState;
Expand Down Expand Up @@ -194,7 +195,7 @@ private DynamicType.Builder<?> doEnhance(DynamicType.Builder<?> builder, TypeDes
if ( collectionFields.isEmpty() ) {
builder = builder.implement( SelfDirtinessTracker.class )
.defineField( EnhancerConstants.TRACKER_FIELD_NAME, DirtyTracker.class, FieldPersistence.TRANSIENT, Visibility.PRIVATE )
.annotateField( AnnotationDescription.Builder.ofType( Transient.class ).build() )
.annotateField( TRANSIENT_ANNOTATION )
.defineMethod( EnhancerConstants.TRACKER_CHANGER_NAME, void.class, Visibility.PUBLIC )
.withParameters( String.class )
.intercept( implementationTrackChange )
Expand All @@ -215,9 +216,9 @@ private DynamicType.Builder<?> doEnhance(DynamicType.Builder<?> builder, TypeDes
//TODO es.enableInterfaceExtendedSelfDirtinessTracker ? Careful with consequences..
builder = builder.implement( ExtendedSelfDirtinessTracker.class )
.defineField( EnhancerConstants.TRACKER_FIELD_NAME, DirtyTracker.class, FieldPersistence.TRANSIENT, Visibility.PRIVATE )
.annotateField( AnnotationDescription.Builder.ofType( Transient.class ).build() )
.annotateField( TRANSIENT_ANNOTATION )
.defineField( EnhancerConstants.TRACKER_COLLECTION_NAME, CollectionTracker.class, FieldPersistence.TRANSIENT, Visibility.PRIVATE )
.annotateField( AnnotationDescription.Builder.ofType( Transient.class ).build() )
.annotateField( TRANSIENT_ANNOTATION )
.defineMethod( EnhancerConstants.TRACKER_CHANGER_NAME, void.class, Visibility.PUBLIC )
.withParameters( String.class )
.intercept( implementationTrackChange )
Expand Down Expand Up @@ -323,7 +324,7 @@ else if ( enhancementContext.isCompositeClass( managedCtClass ) ) {
FieldPersistence.TRANSIENT,
Visibility.PRIVATE
)
.annotateField( AnnotationDescription.Builder.ofType( Transient.class ).build() )
.annotateField( TRANSIENT_ANNOTATION )
.defineMethod(
EnhancerConstants.TRACKER_COMPOSITE_SET_OWNER,
void.class,
Expand Down Expand Up @@ -400,7 +401,7 @@ private static DynamicType.Builder<?> addFieldWithGetterAndSetter(
String setterName) {
return builder
.defineField( fieldName, type, Visibility.PRIVATE, FieldPersistence.TRANSIENT )
.annotateField( AnnotationDescription.Builder.ofType( Transient.class ).build() )
.annotateField( TRANSIENT_ANNOTATION )
.defineMethod( getterName, type, Visibility.PUBLIC )
.intercept( FieldAccessor.ofField( fieldName ) )
.defineMethod( setterName, void.class, Visibility.PUBLIC )
Expand Down

0 comments on commit e7fe516

Please sign in to comment.