-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use builder pattern for CoapRequest and CoapResponse #68
Conversation
@sbernard31 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I took a quick look.
At first sight this sounds good. 🙂
(Note that I didn't try it in my code)
public static Builder fetch(String uriPath) { | ||
return request(Method.FETCH, uriPath); | ||
} | ||
|
||
public static CoapRequest fetch(String uriPath) { | ||
return CoapRequest.of(null, Method.FETCH, uriPath); | ||
public static Builder patch(String uriPath) { | ||
return new Builder(Method.PATCH, uriPath); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clearly a details but :
Some function use request()
and other use new Builder
I don't know if this is intended.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ohh, that's true, no that was not intended, will fix that
public CoapRequest withToken(Opaque newToken) { | ||
return new CoapRequest(method, newToken, options, payload, peerAddress, transContext); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if this kind of modifiers is a good idea 🤔, this looks like it does same job than builder ?
Maybe we should add a method which allow to initialize a builder with a coaprequest ?
e.g. :
new CoapRequest.Builder(coapRequest).token(t).build();
// OR maybe
coaprequest.modify().token(t).build(); // where modify(or a better name) return a builder ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, but I wanted to minimise need to change current code. Later we could add such a method and deprecate all with...
functions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
6cb99d7
to
39184ea
Compare
Merging as there is no more comments. |
Uups, I'm not sure if you expected a confirmation from me ? Sorry about that. I haven't more comments to add, PR looks good to me. |
No description provided.