Skip to content

Commit

Permalink
Extract option check
Browse files Browse the repository at this point in the history
  • Loading branch information
dnestoro committed Apr 8, 2024
1 parent 71687b9 commit b48b52b
Showing 1 changed file with 23 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,28 +48,29 @@ public static EmbeddedResourcesInfo singleton() {
}

public void declareResourceAsRegistered(Module module, String resource, String source) {
if (ResourcesFeature.Options.GenerateEmbeddedResourcesFile.getValue()) {
Resources.ModuleResourceKey key = Resources.createStorageKey(module, resource);
registeredResources.compute(key, (k, v) -> {
if (v == null) {
ArrayList<String> newValue = new ArrayList<>();
newValue.add(source);
return newValue;
}

/*
* We have to avoid duplicated sources here. In case when declaring resource that
* comes from module as registered, we don't have information whether the resource
* is already registered or not. That check is performed later in {@link
* Resources.java#addEntry}, so we have to perform same check here, to avoid
* duplicates when collecting information about resource.
*/
if (!v.contains(source)) {
v.add(source);
}
return v;
});
if (!ResourcesFeature.Options.GenerateEmbeddedResourcesFile.getValue()) {
return;
}
}

Resources.ModuleResourceKey key = Resources.createStorageKey(module, resource);
registeredResources.compute(key, (k, v) -> {
if (v == null) {
ArrayList<String> newValue = new ArrayList<>();
newValue.add(source);
return newValue;
}

/*
* We have to avoid duplicated sources here. In case when declaring resource that comes
* from module as registered, we don't have information whether the resource is already
* registered or not. That check is performed later in {@link Resources.java#addEntry},
* so we have to perform same check here, to avoid duplicates when collecting
* information about resource.
*/
if (!v.contains(source)) {
v.add(source);
}
return v;
});
}
}

0 comments on commit b48b52b

Please sign in to comment.