-
Notifications
You must be signed in to change notification settings - Fork 95
Breaking change - renaming old mutable setXX methods #191
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
Changes from 1 commit
4569c43
533065b
2443363
51c21d5
bdb1011
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -177,7 +177,7 @@ public boolean batchingEnabled() { | |
* @param batchingEnabled {@code true} to enable batch loading, {@code false} otherwise | ||
* @return a new data loader options instance for fluent coding | ||
*/ | ||
public DataLoaderOptions setBatchingEnabled(boolean batchingEnabled) { | ||
public DataLoaderOptions withBatchingEnabled(boolean batchingEnabled) { | ||
return builder().setBatchingEnabled(batchingEnabled).build(); | ||
} | ||
|
||
|
@@ -196,7 +196,7 @@ public boolean cachingEnabled() { | |
* @param cachingEnabled {@code true} to enable caching, {@code false} otherwise | ||
* @return a new data loader options instance for fluent coding | ||
*/ | ||
public DataLoaderOptions setCachingEnabled(boolean cachingEnabled) { | ||
public DataLoaderOptions withCachingEnabled(boolean cachingEnabled) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how about making these static to discourage chaining and removing the newOptions function? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure what you mean by static. But while agree we should have made a compiler breaking change the first time (which we are now) I do still want to retain immutable options chaining. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Chaining is good however even with this change you can still write
Which is breaking I feel like instead if you remove newOptions() and swap to static the IDE will hint the bad pattern of static methods on the instance, no longer recommend chaining on the concrete instance and hint people towards chaining only on the builder ![]() ![]() IDE not suggesting chaining of the static methods ![]() (It will allow you to explicitly type it out but won't suggest it and will warn if you do) This code is technically valid but i feel like we want to push people to the Builder since it exists now ![]() Push people towards proper builder pattern There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Normally I dont mind So you are right, we need to be more clear in this case because of the previous history So I have deleted all the with method and now only have the builder. So every one has to move to a new place which is more sympathetic to immutability Thanks for the feedback. |
||
return builder().setCachingEnabled(cachingEnabled).build(); | ||
} | ||
|
||
|
@@ -220,7 +220,7 @@ public boolean cachingExceptionsEnabled() { | |
* @param cachingExceptionsEnabled {@code true} to enable caching exceptional values, {@code false} otherwise | ||
* @return a new data loader options instance for fluent coding | ||
*/ | ||
public DataLoaderOptions setCachingExceptionsEnabled(boolean cachingExceptionsEnabled) { | ||
public DataLoaderOptions withCachingExceptionsEnabled(boolean cachingExceptionsEnabled) { | ||
return builder().setCachingExceptionsEnabled(cachingExceptionsEnabled).build(); | ||
} | ||
|
||
|
@@ -241,7 +241,7 @@ public Optional<CacheKey> cacheKeyFunction() { | |
* @param cacheKeyFunction the cache key function to use | ||
* @return a new data loader options instance for fluent coding | ||
*/ | ||
public DataLoaderOptions setCacheKeyFunction(CacheKey<?> cacheKeyFunction) { | ||
public DataLoaderOptions withCacheKeyFunction(CacheKey<?> cacheKeyFunction) { | ||
return builder().setCacheKeyFunction(cacheKeyFunction).build(); | ||
} | ||
|
||
|
@@ -262,7 +262,7 @@ public DataLoaderOptions setCacheKeyFunction(CacheKey<?> cacheKeyFunction) { | |
* @param cacheMap the cache map instance | ||
* @return a new data loader options instance for fluent coding | ||
*/ | ||
public DataLoaderOptions setCacheMap(CacheMap<?, ?> cacheMap) { | ||
public DataLoaderOptions withCacheMap(CacheMap<?, ?> cacheMap) { | ||
return builder().setCacheMap(cacheMap).build(); | ||
} | ||
|
||
|
@@ -283,7 +283,7 @@ public int maxBatchSize() { | |
* @param maxBatchSize the maximum batch size | ||
* @return a new data loader options instance for fluent coding | ||
*/ | ||
public DataLoaderOptions setMaxBatchSize(int maxBatchSize) { | ||
public DataLoaderOptions withMaxBatchSize(int maxBatchSize) { | ||
return builder().setMaxBatchSize(maxBatchSize).build(); | ||
} | ||
|
||
|
@@ -302,7 +302,7 @@ public StatisticsCollector getStatisticsCollector() { | |
* @param statisticsCollector the statistics collector to use | ||
* @return a new data loader options instance for fluent coding | ||
*/ | ||
public DataLoaderOptions setStatisticsCollector(Supplier<StatisticsCollector> statisticsCollector) { | ||
public DataLoaderOptions withStatisticsCollector(Supplier<StatisticsCollector> statisticsCollector) { | ||
return builder().setStatisticsCollector(nonNull(statisticsCollector)).build(); | ||
} | ||
|
||
|
@@ -319,7 +319,7 @@ public BatchLoaderContextProvider getBatchLoaderContextProvider() { | |
* @param contextProvider the batch loader context provider | ||
* @return a new data loader options instance for fluent coding | ||
*/ | ||
public DataLoaderOptions setBatchLoaderContextProvider(BatchLoaderContextProvider contextProvider) { | ||
public DataLoaderOptions withBatchLoaderContextProvider(BatchLoaderContextProvider contextProvider) { | ||
return builder().setBatchLoaderContextProvider(nonNull(contextProvider)).build(); | ||
} | ||
|
||
|
@@ -340,7 +340,7 @@ public DataLoaderOptions setBatchLoaderContextProvider(BatchLoaderContextProvide | |
* @param valueCache the value cache instance | ||
* @return a new data loader options instance for fluent coding | ||
*/ | ||
public DataLoaderOptions setValueCache(ValueCache<?, ?> valueCache) { | ||
public DataLoaderOptions withValueCache(ValueCache<?, ?> valueCache) { | ||
return builder().setValueCache(valueCache).build(); | ||
} | ||
|
||
|
@@ -357,7 +357,7 @@ public ValueCacheOptions getValueCacheOptions() { | |
* @param valueCacheOptions the value cache options | ||
* @return a new data loader options instance for fluent coding | ||
*/ | ||
public DataLoaderOptions setValueCacheOptions(ValueCacheOptions valueCacheOptions) { | ||
public DataLoaderOptions withValueCacheOptions(ValueCacheOptions valueCacheOptions) { | ||
return builder().setValueCacheOptions(nonNull(valueCacheOptions)).build(); | ||
} | ||
|
||
|
@@ -375,7 +375,7 @@ public BatchLoaderScheduler getBatchLoaderScheduler() { | |
* @param batchLoaderScheduler the scheduler | ||
* @return a new data loader options instance for fluent coding | ||
*/ | ||
public DataLoaderOptions setBatchLoaderScheduler(BatchLoaderScheduler batchLoaderScheduler) { | ||
public DataLoaderOptions withBatchLoaderScheduler(BatchLoaderScheduler batchLoaderScheduler) { | ||
return builder().setBatchLoaderScheduler(batchLoaderScheduler).build(); | ||
} | ||
|
||
|
@@ -392,7 +392,7 @@ public DataLoaderInstrumentation getInstrumentation() { | |
* @param instrumentation the new {@link DataLoaderInstrumentation} | ||
* @return a new data loader options instance for fluent coding | ||
*/ | ||
public DataLoaderOptions setInstrumentation(DataLoaderInstrumentation instrumentation) { | ||
public DataLoaderOptions withInstrumentation(DataLoaderInstrumentation instrumentation) { | ||
return builder().setInstrumentation(instrumentation).build(); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the object -> mutate -> new object methods are removed and now only in the builder