forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prefer using builder for ComposableIndexTemplate (elastic#101760)
There's a recurring pattern where we make a copy of a `ComposableIndexTemplate` while changing a single property. We tend to use the constructor and manually supply all properties. This isn't very robust when adding properties to the class as you can easily overlook supplying the new property to the copied instance. It also leads to a proliferation of overloaded constructors as changing all callers to use the new constructor is sometimes not feasible as it would create a very large change set. Also, we'd mostly be supplying `null` values for newly added properties in existing test cases anyway. Often, tests are just setting one or two properties and the rest are null values, which doesn't make the tests very readable. The `ComposableIndexTemplate` class already has a `Builder` class. This PR deprecates all constructors of `ComposableIndexTemplate` in favor of using `ComposableIndexTemplate.Bulider`. Changing all constructor call to use the builder everywhere is not feasible as there are too many usages. But the PR uses the builder for all instances where we make a copy with a minor modification. We can think about doing the same for other classes but this is the one where it seems most important based on the large number of constructor overloads and the bugs or almost committed bugs related to this class. Also, conveniently, there's already a builder class for it.
- Loading branch information
1 parent
16cce1f
commit e786cfa
Showing
20 changed files
with
185 additions
and
291 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.