@Nullable private static Set<QualifiedContent.ScopeType> stringToScopes(String folderName) { int value; try { value = Integer.parseInt(folderName, 16); } catch (NumberFormatException e) { return null; } ImmutableSet.Builder<QualifiedContent.ScopeType> scopesBuilder = ImmutableSet.builder(); for (QualifiedContent.ScopeType scope : allScopes()) { if ((scope.getValue() & value) != 0) { scopesBuilder.add(scope); } } ImmutableSet<QualifiedContent.ScopeType> scopes = scopesBuilder.build(); if (scopes.isEmpty()) { return null; } return scopes; }
private static String scopesToString(@NonNull Set<? super Scope> scopes) { int value = 0; for (QualifiedContent.ScopeType scope : (Set<QualifiedContent.ScopeType>) scopes) { value += scope.getValue(); } return String.format("%x", value); }