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

Make Attachment immutable #1120

Closed
philipphofmann opened this issue Dec 16, 2020 · 3 comments · Fixed by #1121
Closed

Make Attachment immutable #1120

philipphofmann opened this issue Dec 16, 2020 · 3 comments · Fixed by #1121
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@philipphofmann
Copy link
Member

Attachment has a setter for contentType. We can remove the setter and pass the param to the constructors instead. This means we need to add two constructors:

public Attachment(final @NotNull String pathname, final @NotNull String filename, final @NotNull String contentType) {
  // ...
}

public Attachment(final @NotNull byte[] bytes, final @NotNull String filename, final @NotNull String contentType) {
  // ...
}

With this, we achieve immutability for Attachments.

@philipphofmann philipphofmann added the enhancement New feature or request label Dec 16, 2020
@philipphofmann philipphofmann self-assigned this Dec 16, 2020
@philipphofmann
Copy link
Member Author

@bruno-garcia, @marandaneto, @maciejwalkowiak any objections to this change?

@marandaneto
Copy link
Contributor

no objections, just out of curiosity, what was the motivation to be a setter before? if none, even better :D

@philipphofmann
Copy link
Member Author

I think I thought having to pass 3 parameters to a constructor is maybe a bit too much and we were not really sure back then if we even need content type. I think 3 parameters are fine. I can't remember what drove me back then.

philipphofmann added a commit that referenced this issue Dec 16, 2020
Removed the setter for contentType and added two new constructors. Now Attachment is immutable.

Fixes GH-1120
philipphofmann added a commit that referenced this issue Dec 16, 2020
Removed the setter for contentType and added two new constructors. Now Attachment is immutable.

Fixes GH-1120
philipphofmann added a commit that referenced this issue Dec 17, 2020
Removed the setter for contentType and added two new constructors. Now Attachment is immutable.

Fixes GH-1120
@philipphofmann philipphofmann added this to the 4.0.0 milestone Dec 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants