Skip to content

Conversation

@MichalFoksa
Copy link
Contributor

@MichalFoksa MichalFoksa commented Jul 25, 2021

To ease customization by a user I suggest to add protected method AvroFormatVisitorWrapper (ex VisitorFormatWrapperImpl) createVisitorWrapper() into AvroFormatVisitorWrapperwhich creates and returns a new instance of visitor wrapper. This method would be used on each place where new visitor instance is created in ArrayVisitor, MapVisitor and RecordVisitor.

By having this in place it is easier to add / modify existing functionality by a user. He just needs to extend existing visitor wrapper and override particular method (just ask me how I know it).

```
protected AvroFormatVisitorWrapper createVisitorFormatWrapperImpl() {
    return new AvroFormatVisitorWrapper(_schemas, _provider);
}
```

@MichalFoksa MichalFoksa changed the title Ease future customization by unifying place where a new visitor is created. [Avro] Ease future customization by unifying place where a new visitor is created. Jul 25, 2021
import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonArrayFormatVisitor;
import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatTypes;
import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitable;
import org.apache.avro.Schema;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not reorder import statements automatically in future... I use ordering from JDK types to non-Jackson types to Jackson types on purpose.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right - reordering is undone.

@cowtowncoder
Copy link
Member

While I am +1 for improving naming, isn't this backwards-incompatible change, and something that can't really go in 2.13 but should wait for 3.0?

@MichalFoksa
Copy link
Contributor Author

:( OK - rename is undone

_provider = p;
}

protected VisitorFormatWrapperImpl createVisitorWrapper() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems odd from naming perspective: type with method to create what seems like (but isn't) a copy.

Would it conceptually be more somethnig like "createChildWrapper()" or "createChildInstance()" or something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have chosen createChildWrapper. Did not find better name.

@cowtowncoder
Copy link
Member

Ok so I think I can see why this is needed. I added a note where naming seems confusing wrt method -- I think I can see why naming of the class is unfortunate.

Once we get past that, maybe it would make sense to also file a follow-up issue about actual renaming like you suggested first. I'd have to think if it actually could go in 2.14, after all, or at least in 3.0.

@cowtowncoder
Copy link
Member

LGTM! Will merge.

@cowtowncoder cowtowncoder merged commit 8aacf59 into FasterXML:2.13 Aug 14, 2021
@MichalFoksa
Copy link
Contributor Author

Thanks!

@MichalFoksa MichalFoksa deleted the feature/2.13/avro/ease-of-customization branch August 14, 2021 05:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants