Skip to content

Commit

Permalink
Stronger encapsulation of collection fields in MavenProject with im…
Browse files Browse the repository at this point in the history
…mutability and defensive copies.

The following rules are applied in this commit (the previous situation was a mix of different practices):

* All getter methods except `getDependencyArtifacts()` return an empty collection instead of null.
* All setter methods except delegates make a defensive copy of the given collection, preserving order.
* All getter methods returns an unmodifiable (but not necessarily immutable) collection.
* The collections of properties that do not have an `addFoo(…)` method are immutable.
* The `clone()` method copies all non-immutable collections, and only them.
* `MavenProject(MavenProject)` assigns fields directly without invoking setter methods.
  • Loading branch information
desruisseaux committed Nov 5, 2024
1 parent 4bed759 commit dbe08cc
Show file tree
Hide file tree
Showing 2 changed files with 225 additions and 141 deletions.
Loading

0 comments on commit dbe08cc

Please sign in to comment.