Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
public abstract class AbstractModelloGenerator implements ModelloGenerator {
private final Logger logger = LoggerFactory.getLogger(getClass());

private static final Map<String, String> PLURAL_EXCEPTIONS = new HashMap<>();
private static final ThreadLocal<Map<String, String>> PLURAL_EXCEPTIONS = ThreadLocal.withInitial(HashMap::new);

private Model model;

Expand Down Expand Up @@ -97,8 +97,9 @@ protected void initialize(Model model, Map<String, Object> parameters) throws Mo

licenseText = (List<String>) parameters.get(ModelloParameterConstants.LICENSE_TEXT);

PLURAL_EXCEPTIONS.get().clear();
Optional.ofNullable(parameters.get(ModelloParameterConstants.PLURAL_EXCEPTIONS))
.ifPresent(o -> PLURAL_EXCEPTIONS.putAll((Map<String, String>) o));
.ifPresent(o -> PLURAL_EXCEPTIONS.get().putAll((Map<String, String>) o));
}

protected Model getModel() {
Expand Down Expand Up @@ -207,8 +208,8 @@ public static String singular(String name) {
return name;
}

if (PLURAL_EXCEPTIONS.containsKey(name)) {
return PLURAL_EXCEPTIONS.get(name);
if (PLURAL_EXCEPTIONS.get().containsKey(name)) {
return PLURAL_EXCEPTIONS.get().get(name);
}

if (name.endsWith("ies")) {
Expand Down