Skip to content

Commit

Permalink
SubscriptionUtil: making checkstyle happy, now with truly final map
Browse files Browse the repository at this point in the history
  • Loading branch information
virgo47 committed Aug 19, 2022
1 parent c7af1a6 commit cac8e51
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
package com.evolveum.midpoint.schema.util;

import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
Expand Down Expand Up @@ -111,19 +113,17 @@ public boolean isCorrect() {
return subscriptionType != null;
}

private static final Map<String, SubscriptionType> codeToType = new HashMap<>();
private static final Map<String, SubscriptionType> CODE_TO_TYPE;

static {
for (SubscriptionType value : values()) {
if (value.subscriptionType != null) {
codeToType.put(value.subscriptionType, value);
}
}
CODE_TO_TYPE = Arrays.stream(values())
.filter(v -> v.subscriptionType != null)
.collect(Collectors.toUnmodifiableMap(v -> v.subscriptionType, Function.identity()));
}

@Nullable
public static SubscriptionType resolveType(String code) {
return codeToType.get(code);
return CODE_TO_TYPE.get(code);
}
}
}

0 comments on commit cac8e51

Please sign in to comment.