Skip to content
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

Merged
merged 2 commits into from
Oct 20, 2023

Conversation

szysas
Copy link
Collaborator

@szysas szysas commented Oct 3, 2023

No description provided.

@szysas
Copy link
Collaborator Author

szysas commented Oct 3, 2023

@sbernard31
This PR addresses your comment #27 (comment)

@szysas szysas requested a review from sbernard31 October 3, 2023 12:55
Copy link
Collaborator

@sbernard31 sbernard31 left a 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)

Comment on lines 76 to 81
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);
Copy link
Collaborator

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.

Copy link
Collaborator Author

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

Comment on lines +172 to 174
public CoapRequest withToken(Opaque newToken) {
return new CoapRequest(method, newToken, options, payload, peerAddress, transContext);
}
Copy link
Collaborator

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 ?

Copy link
Collaborator Author

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

@szysas szysas force-pushed the coap-request-response-builder branch from 6cb99d7 to 39184ea Compare October 19, 2023 17:44
@szysas
Copy link
Collaborator Author

szysas commented Oct 20, 2023

Merging as there is no more comments.

@szysas szysas merged commit e8a35d3 into master Oct 20, 2023
4 checks passed
@szysas szysas deleted the coap-request-response-builder branch October 20, 2023 14:00
@sbernard31
Copy link
Collaborator

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.
In the future, do not hesitate to ping me if needed 🙂

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.

None yet

2 participants