mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-09-12 18:18:55 +00:00
* feat: implement Immutable pattern #3448 Add immutable/ module with ImmutableUser (final class, defensive copy, withAge wither method), App demo, JUnit 5 tests, PlantUML diagram, and README following project conventions. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat: add withName and withRoles wither methods to ImmutableUser #3448 Every field now has a corresponding wither for consistency. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix: add junit-jupiter-api dependency to immutable module #3448 Required for @Test annotations and assert methods in test code. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
22 lines
514 B
Plaintext
22 lines
514 B
Plaintext
@startuml
|
|
package com.iluwatar.immutable {
|
|
class App {
|
|
- LOGGER : Logger {static}
|
|
+ App()
|
|
+ main(args : String[]) {static}
|
|
}
|
|
class ImmutableUser {
|
|
- name : String {final}
|
|
- age : int {final}
|
|
- roles : List<String> {final}
|
|
+ ImmutableUser(name : String, age : int, roles : List<String>)
|
|
+ getName() : String
|
|
+ getAge() : int
|
|
+ getRoles() : List<String>
|
|
+ withAge(newAge : int) : ImmutableUser
|
|
+ toString() : String
|
|
}
|
|
}
|
|
App ..> ImmutableUser : creates
|
|
@enduml
|