Skip to content

Commit f51bc8c

Browse files
docs: add immutability explanation to readme (#497)
1 parent 253cf7f commit f51bc8c

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,14 @@ To send a request to the Lithic API, build an instance of some `Params` class an
108108

109109
For example, `client.cards().create(...)` should be called with an instance of `CardCreateParams`, and it will return an instance of `Card`.
110110

111+
## Immutability
112+
113+
Each class in the SDK has an associated [builder](https://blogs.oracle.com/javamagazine/post/exploring-joshua-blochs-builder-design-pattern-in-java) or factory method for constructing it.
114+
115+
Each class is [immutable](https://docs.oracle.com/javase/tutorial/essential/concurrency/immutable.html) once constructed. If the class has an associated builder, then it has a `toBuilder()` method, which can be used to convert it back to a builder for making a modified copy.
116+
117+
Because each class is immutable, builder modification will _never_ affect already built class instances.
118+
111119
## Asynchronous execution
112120

113121
The default client is synchronous. To switch to asynchronous execution, call the `async()` method:

0 commit comments

Comments
 (0)