I have two types of payload coming from upstream: It's either PayloadA or PayloadB.
PayloadA containes these many fields:
createTimestamp
sentTimestamp
schemaId
eventId
producerId
guid
deviceId
langId
sessionId
PayloadB containes these many fields:
createTimestamp
sentTimestamp
schemaId
eventId
producerId
eventType
payloadVersion
creationDate
expirationSeconds
payload
So first 5 fields are common between them. And in general they will have more fields.
How do I setup my builder pattern for this problem? It looks like I need to use composition here.
- So should I have one
Payloadbuilder pattern class with all the fields from both the payload combined in it? - Or I should have
PayloadAandPayloadBbuilder pattern class inside anotherPayloadbuilder class and the common fields ofPayloadAandPayloadBwill be part ofPayloadclass?
What is the best way to make a builder pattern for this kind of problem. Can anyone provide an example on this problem?
Aucun commentaire:
Enregistrer un commentaire