javafixes.object.changing.builder.UpdateConfigBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of javafixes Show documentation
Show all versions of javafixes Show documentation
Things I would like to have in Java by default
package javafixes.object.changing.builder;
import javafixes.object.changing.config.ChangingValueUpdateConfig;
import javafixes.object.changing.function.valueHandler.AfterReplacedPreviousValueHandler;
import javafixes.object.changing.function.valueHandler.EachPotentialValueHandler;
import javafixes.object.changing.function.replacement.ValueReplacementRule;
import java.util.Optional;
import java.util.function.Consumer;
public class UpdateConfigBuilder {
protected ChangingValueUpdateConfig updateConfig = ChangingValueUpdateConfig.doNothingOnUpdateConfig();
public static UpdateConfigBuilder updateConfigBuilder() {
return new UpdateConfigBuilder<>();
}
public ChangingValueUpdateConfig super T> build() {
return updateConfig;
}
public UpdateConfigBuilder withValueReplacementRule(ValueReplacementRule super T> valueReplacementRule) {
this.updateConfig = new ChangingValueUpdateConfig<>(
Optional.of(valueReplacementRule),
updateConfig.eachPotentialValueHandler,
updateConfig.afterReplacedPreviousValueHandler,
updateConfig.disposeFunction
);
return this;
}
public UpdateConfigBuilder withNOValueReplacementRule() {
this.updateConfig = new ChangingValueUpdateConfig<>(
Optional.empty(),
updateConfig.eachPotentialValueHandler,
updateConfig.afterReplacedPreviousValueHandler,
updateConfig.disposeFunction
);
return this;
}
public UpdateConfigBuilder withValueReplacementRule(Optional> valueReplacementRule) {
this.updateConfig = new ChangingValueUpdateConfig<>(
valueReplacementRule,
updateConfig.eachPotentialValueHandler,
updateConfig.afterReplacedPreviousValueHandler,
updateConfig.disposeFunction
);
return this;
}
public UpdateConfigBuilder withEachPotentialValueHandler(EachPotentialValueHandler super T> eachPotentialValueHandler) {
this.updateConfig = new ChangingValueUpdateConfig<>(
updateConfig.valueReplacementRule,
Optional.of(eachPotentialValueHandler),
updateConfig.afterReplacedPreviousValueHandler,
updateConfig.disposeFunction
);
return this;
}
public UpdateConfigBuilder withNOEachPotentialValueHandler() {
this.updateConfig = new ChangingValueUpdateConfig<>(
updateConfig.valueReplacementRule,
Optional.empty(),
updateConfig.afterReplacedPreviousValueHandler,
updateConfig.disposeFunction
);
return this;
}
public UpdateConfigBuilder withEachPotentialValueHandler(Optional> eachPotentialValueHandler) {
this.updateConfig = new ChangingValueUpdateConfig<>(
updateConfig.valueReplacementRule,
eachPotentialValueHandler,
updateConfig.afterReplacedPreviousValueHandler,
updateConfig.disposeFunction
);
return this;
}
public UpdateConfigBuilder withAfterReplacedPreviousValueHandler(AfterReplacedPreviousValueHandler super T> afterReplacedPreviousValueHandler) {
this.updateConfig = new ChangingValueUpdateConfig<>(
updateConfig.valueReplacementRule,
updateConfig.eachPotentialValueHandler,
Optional.of(afterReplacedPreviousValueHandler),
updateConfig.disposeFunction
);
return this;
}
public UpdateConfigBuilder withNOAfterReplacedPreviousValueHandler() {
this.updateConfig = new ChangingValueUpdateConfig<>(
updateConfig.valueReplacementRule,
updateConfig.eachPotentialValueHandler,
Optional.empty(),
updateConfig.disposeFunction
);
return this;
}
public UpdateConfigBuilder withAfterReplacedPreviousValueHandler(Optional> afterReplacedPreviousValueHandler) {
this.updateConfig = new ChangingValueUpdateConfig<>(
updateConfig.valueReplacementRule,
updateConfig.eachPotentialValueHandler,
afterReplacedPreviousValueHandler,
updateConfig.disposeFunction
);
return this;
}
public UpdateConfigBuilder withDisposeFunction(Consumer super T> disposeFunction) {
this.updateConfig = new ChangingValueUpdateConfig<>(
updateConfig.valueReplacementRule,
updateConfig.eachPotentialValueHandler,
updateConfig.afterReplacedPreviousValueHandler,
Optional.of(disposeFunction)
);
return this;
}
public UpdateConfigBuilder withNODisposeFunction() {
this.updateConfig = new ChangingValueUpdateConfig<>(
updateConfig.valueReplacementRule,
updateConfig.eachPotentialValueHandler,
updateConfig.afterReplacedPreviousValueHandler,
Optional.empty()
);
return this;
}
public UpdateConfigBuilder withDisposeFunction(Optional> disposeFunction) {
this.updateConfig = new ChangingValueUpdateConfig<>(
updateConfig.valueReplacementRule,
updateConfig.eachPotentialValueHandler,
updateConfig.afterReplacedPreviousValueHandler,
disposeFunction
);
return this;
}
public UpdateConfigBuilder withUpdateConfig(ChangingValueUpdateConfig super T> updateConfig) {
this.updateConfig = (ChangingValueUpdateConfig) updateConfig;
return this;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy