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

Use ImmutableMap.Builder.buildKeepingLast() where appropriate. #177

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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 @@ -316,7 +316,7 @@ public ImmutableMap<String, Object> readAttributes(File file, String attributes)
throw new IllegalArgumentException("invalid attributes: " + attributes);
}

Map<String, Object> result = new HashMap<>();
ImmutableMap.Builder<String, Object> result = ImmutableMap.builder();
if (attrs.size() == 1 && attrs.contains(ALL_ATTRIBUTES)) {
// for 'view:*' format, get all keys for all providers for the view
AttributeProvider provider = providersByName.get(view);
Expand All @@ -333,7 +333,7 @@ public ImmutableMap<String, Object> readAttributes(File file, String attributes)
}
}

return ImmutableMap.copyOf(result);
return result.buildKeepingLast();
}

/**
Expand All @@ -351,7 +351,8 @@ public <A extends BasicFileAttributes> A readAttributes(File file, Class<A> type
throw new UnsupportedOperationException("unsupported attributes type: " + type);
}

private static void readAll(File file, AttributeProvider provider, Map<String, Object> map) {
private static void readAll(
File file, AttributeProvider provider, ImmutableMap.Builder<String, Object> map) {
for (String attribute : provider.attributes(file)) {
Object value = provider.get(file, attribute);

Expand Down