com.laamella.parameter_source.SubParameterSource Maven / Gradle / Ivy
package com.laamella.parameter_source;
import java.util.Optional;
import java.util.function.BiFunction;
import static java.util.Objects.requireNonNull;
/**
* Supports the "subSource" method.
*/
public class SubParameterSource implements ParameterSource {
private final ParameterSource delegate;
private final String keyPart;
private final BiFunction keyCombiner;
public SubParameterSource(ParameterSource delegate, String keyPart, BiFunction keyCombiner) {
requireNonNull(delegate);
requireNonNull(keyPart);
requireNonNull(keyCombiner);
this.delegate = delegate;
this.keyPart = keyPart;
this.keyCombiner = keyCombiner;
}
@Override
public Optional getOptionalString(String key) {
requireNonNull(key);
return delegate.getOptionalString(combineKeys(keyPart, key));
}
@Override
public Optional getOptionalInteger(String key) {
requireNonNull(key);
return delegate.getOptionalInteger(combineKeys(keyPart, key));
}
@Override
public Optional