Skip to content

Commit

Permalink
fix 'access is emulated by a synthetic accessor'
Browse files Browse the repository at this point in the history
  • Loading branch information
EcljpseB0T authored and tjwatson committed Dec 5, 2023
1 parent 8c63420 commit 9cc56cc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,20 @@ public ModuleCapability apply(GenericInfo i) {
Map<String, Object> attributes = i.mutable ? copyUnmodifiableMap(i.attributes) : i.attributes;
return new ModuleCapability(i.namespace, directives, attributes, ModuleRevision.this);
}
}, NamespaceList.CAPABILITY).build();
}

private static <K, V> Map<K, V> copyUnmodifiableMap(Map<K, V> map) {
int size = map.size();
if (size == 0) {
return Collections.emptyMap();
}
if (size == 1) {
Map.Entry<K, V> entry = map.entrySet().iterator().next();
return Collections.singletonMap(entry.getKey(), entry.getValue());
}
return Collections.unmodifiableMap(new HashMap<>(map));
private <K, V> Map<K, V> copyUnmodifiableMap(Map<K, V> map) {
int size = map.size();
if (size == 0) {
return Collections.emptyMap();
}
if (size == 1) {
Map.Entry<K, V> entry = map.entrySet().iterator().next();
return Collections.singletonMap(entry.getKey(), entry.getValue());
}
return Collections.unmodifiableMap(new HashMap<>(map));
}

}, NamespaceList.CAPABILITY).build();
}

private NamespaceList<ModuleRequirement> createRequirements(NamespaceList.Builder<GenericInfo> infos) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ public static <E> Builder<E> create(Function<E, String> getNamespace) {

private final Function<E, String> getNamespace;
private LinkedHashMap<String, List<E>> namespaceElements;
private int size = 0;
int size = 0;

private List<E> lastBuildElements;
List<E> lastBuildElements;

private Builder(Function<E, String> getNamespace, int expectedNamespaces) {
this.getNamespace = getNamespace;
Expand Down Expand Up @@ -196,7 +196,6 @@ public E next() {
}

@Override
@SuppressWarnings("synthetic-access")
public void remove() {
inner.remove();
Builder.this.size--;
Expand Down Expand Up @@ -523,7 +522,7 @@ public List<E> apply(String n, List<E> es) {
});
}

private List<E> removeElementsIf(List<E> list, Predicate<? super E> filter) {
List<E> removeElementsIf(List<E> list, Predicate<? super E> filter) {
int sizeBefore = list.size();
list.removeIf(filter);
this.size -= sizeBefore - list.size();
Expand Down

0 comments on commit 9cc56cc

Please sign in to comment.