Example usage for com.google.common.collect Sets immutableEnumSet

List of usage examples for com.google.common.collect Sets immutableEnumSet

Introduction

In this page you can find the example usage for com.google.common.collect Sets immutableEnumSet.

Prototype


@GwtCompatible(serializable = true)
public static <E extends Enum<E>> ImmutableSet<E> immutableEnumSet(Iterable<E> elements) 

Source Link

Document

Returns an immutable set instance containing the given enum elements.

Usage

From source file:org.trnltk.morphology.contextless.rootfinder.ProperNounWithoutApostropheRootFinder.java

@Override
public List<? extends Root> findRootsForPartialInput(TurkishSequence partialInput, TurkishSequence input) {
    final String partialInputUnderlyingString = partialInput.getUnderlyingString();

    if (partialInput.equals(input) && StringUtils.isAllUpperCase(partialInputUnderlyingString)) {
        final Lexeme abbreviationLexeme = new ImmutableLexeme(partialInputUnderlyingString,
                partialInputUnderlyingString, PrimaryPos.Noun, SecondaryPos.Abbreviation, null);
        if (!partialInput.getLastChar().getLetter().isVowel()) {
            // if last letter is not vowel (such as PTT, THY), then add char 'E' to the end and then calculate the phonetics
            final ImmutableSet<PhoneticAttribute> phoneticAttributes = Sets.immutableEnumSet(phoneticsAnalyzer
                    .calculatePhoneticAttributes(partialInput.append(TURKISH_CHAR_E_UPPERCASE), null));
            return Arrays.asList(new ImmutableRoot(partialInput, abbreviationLexeme, phoneticAttributes, null));

        } else {/* w  w  w  . j  a va 2s. c  o  m*/
            final ImmutableSet<PhoneticAttribute> phoneticAttributes = Sets
                    .immutableEnumSet(phoneticsAnalyzer.calculatePhoneticAttributes(partialInput, null));
            return Arrays.asList(new ImmutableRoot(partialInput, abbreviationLexeme, phoneticAttributes, null));
        }
    } else {
        ///XXX : REALLY SMALL SUPPORT!

        // XXX: might be a known proper noun like "Turkce" or "Istanbul". no support for them yet

        // XXX: might be a known proper noun with implicit P3sg. like : Eminonu, Kusadasi.
        // it is important since :
        // 1. Ankara'_y_a but Eminonu'_n_e    : Since this case has apostrophe, it is handled in ProperNounFromApostropheRootFinder
        // 2: P3sg doesn't apply to these words: onun Kusadasi, onun Eminonu
        // 3. Possessions are applied to 'root' : benim Kusadam etc. SKIP this case!

        final Lexeme properNounLexeme = new ImmutableLexeme(partialInputUnderlyingString,
                partialInputUnderlyingString, PrimaryPos.Noun, SecondaryPos.ProperNoun, null);

        final ImmutableSet<PhoneticAttribute> phoneticAttributes = Sets
                .immutableEnumSet(phoneticsAnalyzer.calculatePhoneticAttributes(partialInput, null));
        final ImmutableRoot properNounRoot = new ImmutableRoot(partialInput, properNounLexeme,
                phoneticAttributes, null);
        return Arrays.asList(properNounRoot);
    }
}

From source file:com.android.build.gradle.internal.transforms.JacocoTransform.java

@NonNull
@Override//from  w  ww .  j av  a2 s .c om
public Set<QualifiedContent.Scope> getScopes() {
    // only run on the project classes
    return Sets.immutableEnumSet(QualifiedContent.Scope.PROJECT);
}

From source file:co.mitro.core.server.data.DBAcl.java

public static Set<AccessLevelType> adminAccess() {
    return Sets.immutableEnumSet(AccessLevelType.ADMIN);
}

From source file:com.google.javascript.jscomp.fuzzing.AbstractFuzzer.java

/**
 * @return All types by default. Subclasses may override to limit the
 * supported types/*from   www .j av  a  2  s. com*/
 */
protected Set<Type> supportedTypes() {
    return Sets.immutableEnumSet(EnumSet.allOf(Type.class));
}

From source file:com.facebook.buck.android.DxStep.java

@VisibleForTesting
DxStep(Path outputDexFile, Iterable<Path> filesToDex, EnumSet<Option> options,
        Supplier<String> getPathToCustomDx) {
    this.outputDexFile = Preconditions.checkNotNull(outputDexFile);
    this.filesToDex = ImmutableSet.copyOf(filesToDex);
    this.options = Sets.immutableEnumSet(options);
    this.getPathToCustomDx = Preconditions.checkNotNull(getPathToCustomDx);
}

From source file:org.apache.drill.exec.client.ServerMethod.java

/**
 * Returns the list of methods supported by the server based on its advertised information.
 *
 * @param serverInfos the server information
 * @return a immutable set of capabilities
 *///from   w  w w  . j ava 2 s .c  o  m
static final Set<ServerMethod> getSupportedMethods(Iterable<RpcType> supportedMethods,
        RpcEndpointInfos serverInfos) {
    ImmutableSet.Builder<ServerMethod> builder = ImmutableSet.builder();

    for (RpcType supportedMethod : supportedMethods) {
        ServerMethod method = REVERSE_MAPPING.get(supportedMethod);
        if (method == null) {
            // The server might have newer methods we don't know how to handle yet.
            continue;
        }
        builder.add(method);
    }

    // Fallback to version detection to cover the gap between Drill 1.8.0 and Drill 1.10.0
    if (serverInfos == null) {
        return Sets.immutableEnumSet(builder.build());
    }

    Version serverVersion = UserRpcUtils.getVersion(serverInfos);
    for (ServerMethod capability : ServerMethod.values()) {
        if (serverVersion.compareTo(capability.getMinVersion()) >= 0) {
            builder.add(capability);
        }
    }

    return Sets.immutableEnumSet(builder.build());
}

From source file:com.google.jimfs.PosixAttributeProvider.java

@SuppressWarnings("unchecked")
@Override//from w  w w.  ja  v a  2 s  . co  m
public ImmutableMap<String, ?> defaultValues(Map<String, ?> userProvidedDefaults) {
    Object userProvidedGroup = userProvidedDefaults.get("posix:group");

    UserPrincipal group = DEFAULT_GROUP;
    if (userProvidedGroup != null) {
        if (userProvidedGroup instanceof String) {
            group = createGroupPrincipal((String) userProvidedGroup);
        } else {
            throw new IllegalArgumentException("invalid type " + userProvidedGroup.getClass()
                    + " for attribute 'posix:group': should be one of " + String.class + " or "
                    + GroupPrincipal.class);
        }
    }

    Object userProvidedPermissions = userProvidedDefaults.get("posix:permissions");

    Set<PosixFilePermission> permissions = DEFAULT_PERMISSIONS;
    if (userProvidedPermissions != null) {
        if (userProvidedPermissions instanceof String) {
            permissions = Sets
                    .immutableEnumSet(PosixFilePermissions.fromString((String) userProvidedPermissions));
        } else if (userProvidedPermissions instanceof Set) {
            permissions = toPermissions((Set<?>) userProvidedPermissions);
        } else {
            throw new IllegalArgumentException("invalid type " + userProvidedPermissions.getClass()
                    + " for attribute 'posix:permissions': should be one of " + String.class + " or "
                    + Set.class);
        }
    }

    return ImmutableMap.of("posix:group", group, "posix:permissions", permissions);
}

From source file:com.google.devtools.build.lib.query2.AbstractBlazeQueryEnvironment.java

protected AbstractBlazeQueryEnvironment(boolean keepGoing, boolean strictScope, Predicate<Label> labelFilter,
        EventHandler eventHandler, Set<Setting> settings, Iterable<QueryFunction> extraFunctions,
        QueryExpressionEvalListener<T> evalListener) {
    this.eventHandler = new ErrorSensingEventHandler(eventHandler);
    this.keepGoing = keepGoing;
    this.strictScope = strictScope;
    this.dependencyFilter = constructDependencyFilter(settings);
    this.labelFilter = labelFilter;
    this.settings = Sets.immutableEnumSet(settings);
    this.extraFunctions = ImmutableList.copyOf(extraFunctions);
    this.evalListener = evalListener;
}

From source file:org.trnltk.morphology.lexicon.ImmutableRootGenerator.java

public HashSet<ImmutableRoot> generate(final Lexeme lexeme) {
    if (CollectionUtils.containsAny(lexeme.getAttributes(), MODIFIERS_TO_WATCH)) {
        return this.generateModifiedRootNodes(lexeme);
    } else {//from ww w . j  av a  2s.  c  om
        Set<PhoneticAttribute> phoneticAttributes = phoneticsAnalyzer
                .calculatePhoneticAttributes(lexeme.getLemmaRoot(), lexeme.getAttributes());
        final ImmutableRoot root = new ImmutableRoot(lexeme.getLemmaRoot(), lexeme,
                Sets.immutableEnumSet(phoneticAttributes), null);
        return Sets.newHashSet(root);
    }
}

From source file:edu.mit.streamjit.util.bytecode.Method.java

public Method(java.lang.reflect.Method method, Klass parent) {
    super(parent.getParent().types().getMethodType(method), method.getName());
    //parent is set by our parent adding us to its list prior to making it
    //unmodifiable.  (We can't add ourselves and have the list wrapped
    //unmodifiable later because it's stored in a final field.)
    this.modifiers = Sets.immutableEnumSet(Modifier.fromMethodBits(Shorts.checkedCast(method.getModifiers())));
    //We're unresolved, so we don't have arguments or basic blocks.
    this.localVariables = null;
}