Skip to content
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

HDDS-11149. Have a generic version Validator for validating Requests #6932

Draft
wants to merge 12 commits into
base: master
Choose a base branch
from
Draft
Prev Previous commit
Next Next commit
Merge remote-tracking branch 'origin/master' into HDDS-11149
  • Loading branch information
adoroszlai committed Jul 12, 2024
commit b77d1bf8cca1b1e16a369c6ea6c4c114edb5d26b
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ void initMaps(Collection<Method> describedValidators) {
for (ValidationCondition condition : descriptor.conditions()) {
EnumMap<Type, EnumMap<RequestProcessingPhase, List<Method>>>
requestTypeMap = getAndInitialize(
condition, this::newTypeMap, validators);
condition, this::newTypeMap, validators);
EnumMap<RequestProcessingPhase, List<Method>> phases = getAndInitialize(
requestType, this::newPhaseMap, requestTypeMap);
if (isPreProcessValidator(descriptor)) {
Expand Down Expand Up @@ -251,8 +251,8 @@ private EnumMap<RequestProcessingPhase, List<Method>> newPhaseMap() {
return new EnumMap<>(RequestProcessingPhase.class);
}

private <K, V> V getAndInitialize(K key, Supplier<V> defaultValue, Map<K, V> from) {
return from.compute(key, (k, v) -> v == null ? defaultValue.get() : v);
private <K, V> V getAndInitialize(K key, Supplier<V> defaultSupplier, Map<K, V> from) {
return from.computeIfAbsent(key, k -> defaultSupplier.get());
}

private boolean isPreProcessValidator(RequestFeatureValidator descriptor) {
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.