Formatter should be static
See original GitHub issueI noticed the formatter lives within the CloudEvent object.
CloudEvent {
spec:
Spec1 {
payload:
{ specversion: '1.0',
id: '1234',
time: '2020-05-28T20:46:18.970Z',
source: '/some/source',
type: 'example',
datacontenttype: undefined,
data: undefined,
subject: undefined } },
formatter: JSONFormatter {},
extensions: [] }
This doesn’t really make sense since we can have 1000 CloudEvent objects with the same formatter.
Maybe it should be a static class/set of methods.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Can I create only one static instance of DateTimeFormatter
Yes, it is possible. Your variable is Thread Safe because it is immutable - No other thread can change it. Other solutions are...
Read more >DateTimeFormatter (Java Platform SE 8 ) - Oracle Help Center
Gets the overriding zone to be used during formatting. static DateTimeFormatter · ofLocalizedDate(FormatStyle dateStyle). Returns a locale specific date format ...
Read more >Shared API for package java.time.format - Elastic
See the Shared API for a high-level overview of all packages and classes. DateTimeFormatteredit. static DateTimeFormatter BASIC_ISO_DATE; static ...
Read more >How to use DateFormatter in Swift - Sarunw
Since both creating and updating DateFormatter are expensive, we create a static DateFormatter for every possible style in our app here.
Read more >DateFormatConstant - Error Prone
4 requires CONSTANT_CASE to only be used for static final fields whose contents are deeply immutable and whose methods have no detectable side...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I was thinking actually of removing it entirely from the class, along with the
format()
function. Instead, expose a top levelFormatter
class orformatter()
function that takes aCloudEvent
and formats it as JSON by default. But of course that would be a breaking change and require a version bump. Making it static is a good first step.Probably going to hold off on this since it will be part of #226
should we close?