Example usage for com.google.common.collect ImmutableSet isEmpty

List of usage examples for com.google.common.collect ImmutableSet isEmpty

Introduction

In this page you can find the example usage for com.google.common.collect ImmutableSet isEmpty.

Prototype

boolean isEmpty();

Source Link

Document

Returns true if this set contains no elements.

Usage

From source file:com.google.api.codegen.MethodConfig.java

/**
 * Creates an instance of MethodConfig based on MethodConfigProto, linking it up with the provided
 * method. On errors, null will be returned, and diagnostics are reported to the diag collector.
 *//*from   ww w  .  j  a v  a 2s .c o m*/
@Nullable
public static MethodConfig createMethodConfig(DiagCollector diagCollector,
        final MethodConfigProto methodConfigProto, Method method, ImmutableSet<String> retryCodesConfigNames,
        ImmutableSet<String> retryParamsConfigNames) {

    boolean error = false;

    PageStreamingConfig pageStreaming;
    if (PageStreamingConfigProto.getDefaultInstance().equals(methodConfigProto.getPageStreaming())) {
        pageStreaming = null;
    } else {
        pageStreaming = PageStreamingConfig.createPageStreaming(diagCollector,
                methodConfigProto.getPageStreaming(), method);
        if (pageStreaming == null) {
            error = true;
        }
    }

    FlatteningConfig flattening;
    if (FlatteningConfigProto.getDefaultInstance().equals(methodConfigProto.getFlattening())) {
        flattening = null;
    } else {
        flattening = FlatteningConfig.createFlattening(diagCollector, methodConfigProto.getFlattening(),
                method);
        if (flattening == null) {
            error = true;
        }
    }

    BundlingConfig bundling;
    if (BundlingConfigProto.getDefaultInstance().equals(methodConfigProto.getBundling())) {
        bundling = null;
    } else {
        bundling = BundlingConfig.createBundling(diagCollector, methodConfigProto.getBundling(), method);
        if (bundling == null) {
            error = true;
        }
    }

    String retryCodesName = methodConfigProto.getRetryCodesName();
    if (!retryCodesName.isEmpty() && !retryCodesConfigNames.contains(retryCodesName)) {
        diagCollector.addDiag(Diag.error(SimpleLocation.TOPLEVEL,
                "Retry codes config used but not defined: '%s' (in method %s)", retryCodesName,
                method.getFullName()));
        error = true;
    }

    String retryParamsName = methodConfigProto.getRetryParamsName();
    if (!retryParamsConfigNames.isEmpty() && !retryParamsConfigNames.contains(retryParamsName)) {
        diagCollector.addDiag(Diag.error(SimpleLocation.TOPLEVEL,
                "Retry parameters config used but not defined: %s (in method %s)", retryParamsName,
                method.getFullName()));
        error = true;
    }

    Duration timeout = Duration.millis(methodConfigProto.getTimeoutMillis());
    if (timeout.getMillis() <= 0) {
        diagCollector.addDiag(Diag.error(SimpleLocation.TOPLEVEL,
                "Default timeout not found or has invalid value (in method %s)", method.getFullName()));
        error = true;
    }

    boolean hasRequestObjectMethod = methodConfigProto.getRequestObjectMethod();

    List<String> requiredFieldNames = methodConfigProto.getRequiredFieldsList();
    ImmutableSet.Builder<Field> builder = ImmutableSet.builder();
    for (String fieldName : requiredFieldNames) {
        Field requiredField = method.getInputMessage().lookupField(fieldName);
        if (requiredField != null) {
            builder.add(requiredField);
        } else {
            Diag.error(SimpleLocation.TOPLEVEL, "Required field '%s' not found (in method %s)", fieldName,
                    method.getFullName());
            error = true;
        }
    }
    Set<Field> requiredFields = builder.build();

    Iterable<Field> optionalFields = Iterables.filter(method.getInputType().getMessageType().getFields(),
            new Predicate<Field>() {
                @Override
                public boolean apply(Field input) {
                    return !(methodConfigProto.getRequiredFieldsList().contains(input.getSimpleName()));
                }
            });

    ImmutableMap<String, String> fieldNamePatterns = ImmutableMap
            .copyOf(methodConfigProto.getFieldNamePatterns());

    List<String> sampleCodeInitFields = new ArrayList<>();
    sampleCodeInitFields.addAll(methodConfigProto.getRequiredFieldsList());
    sampleCodeInitFields.addAll(methodConfigProto.getSampleCodeInitFieldsList());

    if (error) {
        return null;
    } else {
        return new MethodConfig(pageStreaming, flattening, retryCodesName, retryParamsName, timeout, bundling,
                hasRequestObjectMethod, requiredFields, optionalFields, fieldNamePatterns,
                sampleCodeInitFields);
    }
}

From source file:eu.eidas.node.auth.connector.AUCONNECTORSAML.java

private void checkIdentifierFormat(IAuthenticationResponse authnResponse) throws InternalErrorEIDASException {
    String patterEidentifier = "^[A-Z]{2}/[A-Z]{2}/[A-Za-z0-9+/=\r\n]+$";
    if (authnResponse.getAttributes() != null) {
        ImmutableSet personIdentifier = authnResponse.getAttributes().getAttributeValuesByNameUri(
                EidasSpec.Definitions.PERSON_IDENTIFIER.getNameUri().toASCIIString());
        if (personIdentifier != null && !personIdentifier.isEmpty()) {
            if (!Pattern.matches(patterEidentifier,
                    ((StringAttributeValue) personIdentifier.iterator().next()).getValue())) {
                throw new InternalErrorEIDASException(EidasErrorKey.COLLEAGUE_RESP_INVALID_SAML.errorCode(),
                        "Person Identifier has an invalid format.");
            }//from w ww .  j a va 2  s.c  o m
        }
        ImmutableSet legalPersonIdentifier = authnResponse.getAttributes().getAttributeValuesByNameUri(
                EidasSpec.Definitions.LEGAL_PERSON_IDENTIFIER.getNameUri().toASCIIString());
        if (legalPersonIdentifier != null && !legalPersonIdentifier.isEmpty()) {
            if (!Pattern.matches(patterEidentifier,
                    ((StringAttributeValue) legalPersonIdentifier.iterator().next()).getValue())) {
                throw new InternalErrorEIDASException(EidasErrorKey.COLLEAGUE_RESP_INVALID_SAML.errorCode(),
                        "Legal person Identifier has an invalid format.");
            }

        }
    }

}

From source file:com.google.api.codegen.config.DiscoGapicMethodConfig.java

/**
 * Creates an instance of DiscoGapicMethodConfig based on MethodConfigProto, linking it up with
 * the provided method. On errors, null will be returned, and diagnostics are reported to the diag
 * collector./*from  www .j  av  a 2s .co m*/
 */
@Nullable
static DiscoGapicMethodConfig createDiscoGapicMethodConfig(DiscoApiModel apiModel, TargetLanguage language,
        MethodConfigProto methodConfigProto, Method method, ResourceNameMessageConfigs messageConfigs,
        ImmutableMap<String, ResourceNameConfig> resourceNameConfigs,
        ImmutableSet<String> retryCodesConfigNames, ImmutableSet<String> retryParamsConfigNames) {

    boolean error = false;
    DiscoveryMethodModel methodModel = new DiscoveryMethodModel(method, apiModel);
    DiagCollector diagCollector = apiModel.getDiagCollector();

    PageStreamingConfig pageStreaming = null;
    if (!PageStreamingConfigProto.getDefaultInstance().equals(methodConfigProto.getPageStreaming())) {
        pageStreaming = PageStreamingConfig.createPageStreaming(diagCollector, messageConfigs,
                resourceNameConfigs, methodConfigProto, methodModel);
        if (pageStreaming == null) {
            error = true;
        }
    }

    ImmutableList<FlatteningConfig> flattening = null;
    if (!FlatteningConfigProto.getDefaultInstance().equals(methodConfigProto.getFlattening())) {
        flattening = createFlattening(diagCollector, messageConfigs, resourceNameConfigs, methodConfigProto,
                methodModel);
        if (flattening == null) {
            error = true;
        }
    }

    BatchingConfig batching = null;
    if (!BatchingConfigProto.getDefaultInstance().equals(methodConfigProto.getBatching())) {
        batching = BatchingConfig.createBatching(diagCollector, methodConfigProto.getBatching(), methodModel);
        if (batching == null) {
            error = true;
        }
    }

    String retryCodesName = methodConfigProto.getRetryCodesName();
    if (!retryCodesName.isEmpty() && !retryCodesConfigNames.contains(retryCodesName)) {
        diagCollector.addDiag(Diag.error(SimpleLocation.TOPLEVEL,
                "Retry codes config used but not defined: '%s' (in method %s)", retryCodesName,
                methodModel.getFullName()));
        error = true;
    }

    String retryParamsName = methodConfigProto.getRetryParamsName();
    if (!retryParamsConfigNames.isEmpty() && !retryParamsConfigNames.contains(retryParamsName)) {
        diagCollector.addDiag(Diag.error(SimpleLocation.TOPLEVEL,
                "Retry parameters config used but not defined: %s (in method %s)", retryParamsName,
                methodModel.getFullName()));
        error = true;
    }

    Duration timeout = Duration.ofMillis(methodConfigProto.getTimeoutMillis());
    if (timeout.toMillis() <= 0) {
        diagCollector.addDiag(Diag.error(SimpleLocation.TOPLEVEL,
                "Default timeout not found or has invalid value (in method %s)", methodModel.getFullName()));
        error = true;
    }

    boolean hasRequestObjectMethod = methodConfigProto.getRequestObjectMethod();

    ImmutableMap<String, String> fieldNamePatterns = ImmutableMap
            .copyOf(methodConfigProto.getFieldNamePatterns());

    ResourceNameTreatment defaultResourceNameTreatment = methodConfigProto.getResourceNameTreatment();
    if (defaultResourceNameTreatment == null
            || defaultResourceNameTreatment.equals(ResourceNameTreatment.UNSET_TREATMENT)) {
        defaultResourceNameTreatment = ResourceNameTreatment.NONE;
    }

    List<String> requiredFieldsList = Lists.newArrayList(methodConfigProto.getRequiredFieldsList());
    if (methodModel.hasExtraFieldMask()) {
        requiredFieldsList.add(DiscoveryMethodTransformer.FIELDMASK_STRING);
    }
    Iterable<FieldConfig> requiredFieldConfigs = createFieldNameConfigs(diagCollector, messageConfigs,
            defaultResourceNameTreatment, fieldNamePatterns, resourceNameConfigs,
            getRequiredFields(diagCollector, methodModel, requiredFieldsList));

    Iterable<FieldConfig> optionalFieldConfigs = createFieldNameConfigs(diagCollector, messageConfigs,
            defaultResourceNameTreatment, fieldNamePatterns, resourceNameConfigs,
            getOptionalFields(methodModel, requiredFieldsList));

    List<String> sampleCodeInitFields = new ArrayList<>();
    sampleCodeInitFields.addAll(methodConfigProto.getSampleCodeInitFieldsList());
    SampleSpec sampleSpec = new SampleSpec(methodConfigProto);

    VisibilityConfig visibility = VisibilityConfig.PUBLIC;
    ReleaseLevel releaseLevel = ReleaseLevel.ALPHA;
    for (SurfaceTreatmentProto treatment : methodConfigProto.getSurfaceTreatmentsList()) {
        if (!treatment.getIncludeLanguagesList().contains(language.toString().toLowerCase())) {
            continue;
        }
        if (treatment.getVisibility() != VisibilityProto.UNSET_VISIBILITY) {
            visibility = VisibilityConfig.fromProto(treatment.getVisibility());
        }
        if (treatment.getReleaseLevel() != ReleaseLevel.UNSET_RELEASE_LEVEL) {
            releaseLevel = treatment.getReleaseLevel();
        }
    }

    LongRunningConfig longRunningConfig = null;

    if (error) {
        return null;
    } else {
        return new AutoValue_DiscoGapicMethodConfig(methodModel, pageStreaming, flattening, retryCodesName,
                retryParamsName, timeout, requiredFieldConfigs, optionalFieldConfigs,
                defaultResourceNameTreatment, batching, hasRequestObjectMethod, fieldNamePatterns,
                sampleCodeInitFields, sampleSpec, visibility, releaseLevel, longRunningConfig);
    }
}

From source file:com.facebook.buck.ide.intellij.IjProjectCommandHelper.java

public int parseTargetsAndRunProjectGenerator(List<String> arguments) throws IOException, InterruptedException {
    if (projectView != null && arguments.isEmpty()) {
        console.getStdErr().println("\nParams are view_path target(s), but you didn't supply any targets");

        return 1;
    }/*  w w  w . jav  a 2 s.com*/

    List<String> targets = arguments;
    if (targets.isEmpty()) {
        targets = ImmutableList.of("//...");
    }

    ImmutableSet<BuildTarget> passedInTargetsSet;
    TargetGraph projectGraph;

    try {
        ParserConfig parserConfig = buckConfig.getView(ParserConfig.class);
        passedInTargetsSet = ImmutableSet.copyOf(Iterables.concat(parser.resolveTargetSpecs(buckEventBus, cell,
                enableParserProfiling, executor, argsParser.apply(targets), SpeculativeParsing.of(true),
                parserConfig.getDefaultFlavorsMode())));
        projectGraph = getProjectGraphForIde(executor, passedInTargetsSet);
    } catch (BuildTargetException | BuildFileParseException | HumanReadableException e) {
        buckEventBus.post(ConsoleEvent.severe(MoreExceptions.getHumanReadableOrLocalizedMessage(e)));
        return 1;
    }

    ImmutableSet<BuildTarget> graphRoots;
    if (passedInTargetsSet.isEmpty()) {
        graphRoots = projectGraph.getNodes().stream().map(TargetNode::getBuildTarget)
                .collect(MoreCollectors.toImmutableSet());
    } else {
        graphRoots = passedInTargetsSet;
    }

    TargetGraphAndTargets targetGraphAndTargets;
    try {
        targetGraphAndTargets = createTargetGraph(projectGraph, graphRoots, passedInTargetsSet.isEmpty(),
                executor);
    } catch (BuildFileParseException | TargetGraph.NoSuchNodeException | BuildTargetException
            | HumanReadableException e) {
        buckEventBus.post(ConsoleEvent.severe(MoreExceptions.getHumanReadableOrLocalizedMessage(e)));
        return 1;
    }

    if (projectView != null) {
        if (isWithTests()) {
            projectGraph = targetGraphAndTargets.getTargetGraph();
        }
        return ProjectView.run(console.getStdErr(), dryRun, isWithTests(), projectView, projectGraph,
                passedInTargetsSet, getActionGraph(projectGraph), buckConfig.getConfig());
    }

    if (dryRun) {
        for (TargetNode<?, ?> targetNode : targetGraphAndTargets.getTargetGraph().getNodes()) {
            console.getStdOut().println(targetNode.toString());
        }

        return 0;
    }

    return runIntellijProjectGenerator(targetGraphAndTargets);
}

From source file:com.facebook.buck.features.go.GoProjectCommandHelper.java

public ExitCode parseTargetsAndRunProjectGenerator(List<String> arguments) throws Exception {
    List<String> targets = arguments;
    if (targets.isEmpty()) {
        targets = ImmutableList.of("//...");
    }/* w  w w.j  a va2  s  . c  o  m*/

    ImmutableSet<BuildTarget> passedInTargetsSet;
    TargetGraph projectGraph;

    try {
        passedInTargetsSet = ImmutableSet.copyOf(Iterables.concat(
                parser.resolveTargetSpecs(parsingContext, argsParser.apply(targets), targetConfiguration)));
        projectGraph = getProjectGraphForIde(passedInTargetsSet);
    } catch (BuildFileParseException e) {
        buckEventBus.post(ConsoleEvent.severe(MoreExceptions.getHumanReadableOrLocalizedMessage(e)));
        return ExitCode.PARSE_ERROR;
    } catch (HumanReadableException e) {
        buckEventBus.post(ConsoleEvent.severe(MoreExceptions.getHumanReadableOrLocalizedMessage(e)));
        return ExitCode.BUILD_ERROR;
    }

    ImmutableSet<BuildTarget> graphRoots;
    if (passedInTargetsSet.isEmpty()) {
        graphRoots = projectGraph.getNodes().stream().map(TargetNode::getBuildTarget)
                .collect(ImmutableSet.toImmutableSet());
    } else {
        graphRoots = passedInTargetsSet;
    }

    TargetGraphAndTargets targetGraphAndTargets;
    try {
        targetGraphAndTargets = createTargetGraph(projectGraph, graphRoots, passedInTargetsSet.isEmpty());
    } catch (BuildFileParseException | NoSuchTargetException | VersionException e) {
        buckEventBus.post(ConsoleEvent.severe(MoreExceptions.getHumanReadableOrLocalizedMessage(e)));
        return ExitCode.PARSE_ERROR;
    } catch (HumanReadableException e) {
        buckEventBus.post(ConsoleEvent.severe(MoreExceptions.getHumanReadableOrLocalizedMessage(e)));
        return ExitCode.BUILD_ERROR;
    }

    if (projectGeneratorParameters.isDryRun()) {
        for (TargetNode<?> targetNode : targetGraphAndTargets.getTargetGraph().getNodes()) {
            console.getStdOut().println(targetNode.toString());
        }

        return ExitCode.SUCCESS;
    }
    return initGoWorkspace(targetGraphAndTargets);
}

From source file:com.facebook.buck.features.project.intellij.IjProjectCommandHelper.java

public ExitCode parseTargetsAndRunProjectGenerator(List<String> arguments)
        throws IOException, InterruptedException {
    if (updateOnly && projectConfig.getAggregationMode() != AggregationMode.NONE) {
        throw new CommandLineException("`--regenerate` option is incompatible with IntelliJ"
                + " module aggregation. In order to use `--regenerate` set `--intellij-aggregation-mode=none`");
    }// w  w  w .ja  v a 2 s  .  c  om

    List<String> targets = arguments;
    if (targets.isEmpty()) {
        targets = ImmutableList.of("//...");
    }

    ImmutableSet<BuildTarget> passedInTargetsSet;
    TargetGraph projectGraph;

    try {
        passedInTargetsSet = ImmutableSet.copyOf(Iterables.concat(
                parser.resolveTargetSpecs(parsingContext, argsParser.apply(targets), targetConfiguration)));
        projectGraph = getProjectGraphForIde(passedInTargetsSet);
    } catch (BuildFileParseException e) {
        buckEventBus.post(ConsoleEvent.severe(MoreExceptions.getHumanReadableOrLocalizedMessage(e)));
        return ExitCode.PARSE_ERROR;
    } catch (HumanReadableException e) {
        buckEventBus.post(ConsoleEvent.severe(MoreExceptions.getHumanReadableOrLocalizedMessage(e)));
        return ExitCode.BUILD_ERROR;
    }

    ImmutableSet<BuildTarget> graphRoots;
    if (passedInTargetsSet.isEmpty()) {
        graphRoots = projectGraph.getNodes().stream().map(TargetNode::getBuildTarget)
                .collect(ImmutableSet.toImmutableSet());
    } else {
        graphRoots = passedInTargetsSet;
    }

    TargetGraphAndTargets targetGraphAndTargets;
    try {
        targetGraphAndTargets = createTargetGraph(projectGraph, graphRoots, passedInTargetsSet.isEmpty());
    } catch (BuildFileParseException | NoSuchTargetException | VersionException e) {
        buckEventBus.post(ConsoleEvent.severe(MoreExceptions.getHumanReadableOrLocalizedMessage(e)));
        return ExitCode.PARSE_ERROR;
    } catch (HumanReadableException e) {
        buckEventBus.post(ConsoleEvent.severe(MoreExceptions.getHumanReadableOrLocalizedMessage(e)));
        return ExitCode.BUILD_ERROR;
    }

    if (projectGeneratorParameters.isDryRun()) {
        for (TargetNode<?> targetNode : targetGraphAndTargets.getTargetGraph().getNodes()) {
            console.getStdOut().println(targetNode.toString());
        }

        return ExitCode.SUCCESS;
    }

    return runIntellijProjectGenerator(targetGraphAndTargets);
}

From source file:com.github.jsdossier.Config.java

/**
 * Creates a new runtime configuration./*ww w  .  ja va  2 s.  c o m*/
 *
 *
 * @param srcs The list of compiler input sources.
 * @param modules The list of CommonJS compiler input sources.
 * @param externs The list of extern files for the Closure compiler.
 * @param excludes The list of excluded files.
 * @param typeFilters The list of types to filter from generated output.
 * @param output Path to the output directory.
 * @param isZipOutput Whether the output directory belongs to a zip file system.
 * @param readme Path to a markdown file to include in the main index.
 * @param customPages Custom markdown files to include in the generated documentation.
 * @param modulePrefix Prefix to strip from each module path when rendering documentation.
 * @param strict Whether to enable all type checks.
 * @param useMarkdown Whether to use markdown for comment parser.
 * @param language The JavaScript dialog sources must conform to.
 * @param outputStream The stream to use for standard output.
 * @param errorStream The stream to use for error output.
 * @throws IllegalStateException If any of source, moudle, and extern sets intersect, or if the
 *     output path is not a directory.
 */
private Config(ImmutableSet<Path> srcs, ImmutableSet<Path> modules, ImmutableSet<Path> externs,
        ImmutableSet<Path> excludes, ImmutableSet<Pattern> typeFilters, boolean isZipOutput, Path output,
        Optional<Path> readme, List<Page> customPages, Optional<Path> modulePrefix, boolean strict,
        boolean useMarkdown, Language language, PrintStream outputStream, PrintStream errorStream,
        FileSystem fileSystem) {
    checkArgument(!srcs.isEmpty() || !modules.isEmpty(), "There must be at least one input source or module");
    checkArgument(intersection(srcs, externs).isEmpty(),
            "The sources and externs inputs must be disjoint:\n  sources: %s\n  externs: %s", srcs, externs);
    checkArgument(intersection(srcs, modules).isEmpty(),
            "The sources and modules inputs must be disjoint:\n  sources: %s\n  modules: %s", srcs, modules);
    checkArgument(intersection(modules, externs).isEmpty(),
            "The sources and modules inputs must be disjoint:\n  modules: %s\n  externs: %s", modules, externs);
    checkArgument(!exists(output) || isDirectory(output), "Output path, %s, is not a directory", output);
    checkArgument(!readme.isPresent() || exists(readme.get()), "README path, %s, does not exist",
            readme.orNull());
    for (Page page : customPages) {
        checkArgument(exists(page.getPath()), "For custom page \"%s\", file does not exist: %s", page.getName(),
                page.getPath());
    }

    this.srcs = srcs;
    this.modules = modules;
    this.srcPrefix = getSourcePrefixPath(fileSystem, srcs, modules);
    this.modulePrefix = getModulePreixPath(fileSystem, modulePrefix, modules);
    this.externs = externs;
    this.excludes = excludes;
    this.typeFilters = typeFilters;
    this.output = output;
    this.isZipOutput = isZipOutput;
    this.readme = readme;
    this.customPages = ImmutableList.copyOf(customPages);
    this.strict = strict;
    this.useMarkdown = useMarkdown;
    this.language = language;
    this.outputStream = outputStream;
    this.errorStream = errorStream;
    this.fileSystem = fileSystem;
}

From source file:com.google.gerrit.server.account.CapabilityCollection.java

@Inject
CapabilityCollection(SystemGroupBackend systemGroupBackend,
        @AdministrateServerGroups ImmutableSet<GroupReference> admins,
        @Assisted @Nullable AccessSection section) {
    this.systemGroupBackend = systemGroupBackend;

    if (section == null) {
        section = new AccessSection(AccessSection.GLOBAL_CAPABILITIES);
    }/*from ww w .j av  a 2 s . co  m*/

    Map<String, List<PermissionRule>> tmp = new HashMap<>();
    for (Permission permission : section.getPermissions()) {
        for (PermissionRule rule : permission.getRules()) {
            if (!permission.getName().equals(GlobalCapability.EMAIL_REVIEWERS)
                    && rule.getAction() == PermissionRule.Action.DENY) {
                continue;
            }

            List<PermissionRule> r = tmp.get(permission.getName());
            if (r == null) {
                r = new ArrayList<>(2);
                tmp.put(permission.getName(), r);
            }
            r.add(rule);
        }
    }
    configureDefaults(tmp, section);
    if (!tmp.containsKey(GlobalCapability.ADMINISTRATE_SERVER) && !admins.isEmpty()) {
        tmp.put(GlobalCapability.ADMINISTRATE_SERVER, ImmutableList.<PermissionRule>of());
    }

    ImmutableMap.Builder<String, ImmutableList<PermissionRule>> m = ImmutableMap.builder();
    for (Map.Entry<String, List<PermissionRule>> e : tmp.entrySet()) {
        List<PermissionRule> rules = e.getValue();
        if (GlobalCapability.ADMINISTRATE_SERVER.equals(e.getKey())) {
            rules = mergeAdmin(admins, rules);
        }
        m.put(e.getKey(), ImmutableList.copyOf(rules));
    }
    permissions = m.build();

    administrateServer = getPermission(GlobalCapability.ADMINISTRATE_SERVER);
    batchChangesLimit = getPermission(GlobalCapability.BATCH_CHANGES_LIMIT);
    emailReviewers = getPermission(GlobalCapability.EMAIL_REVIEWERS);
    priority = getPermission(GlobalCapability.PRIORITY);
    queryLimit = getPermission(GlobalCapability.QUERY_LIMIT);
}

From source file:com.facebook.buck.apple.project_generator.ProjectGenerator.java

/**
 * Returns true if a target matches a set of unflavored targets or the main target.
 *
 * @param focusModules Set of unflavored targets.
 * @param buildTarget Target to test against the set of unflavored targets.
 *
 * @return {@code true} if the target is member of {@code focusModules}.
 */// w  w  w .j a v  a  2s  .c om
public static boolean shouldIncludeBuildTargetIntoFocusedProject(
        ImmutableSet<UnflavoredBuildTarget> focusModules, BuildTarget buildTarget) {
    if (focusModules.isEmpty()) {
        return true;
    }

    return focusModules.contains(buildTarget.getUnflavoredBuildTarget());
}

From source file:dagger.internal.codegen.BindingMethodValidator.java

/**
 * Adds errors if the method has more than one {@linkplain MultibindingAnnotations multibinding
 * annotation} or if it has a multibinding annotation and its {@link Provides} or {@link Produces}
 * annotation has a {@code type} parameter.
 *//*ww  w . ja va 2  s.c  o m*/
protected void checkMultibindings(ValidationReport.Builder<ExecutableElement> builder) {
    if (!allowsMultibindings.allowsMultibindings()) {
        return;
    }
    ImmutableSet<AnnotationMirror> multibindingAnnotations = MultibindingAnnotations
            .forMethod(builder.getSubject());
    if (multibindingAnnotations.size() > 1) {
        for (AnnotationMirror annotation : multibindingAnnotations) {
            builder.addError(formatErrorMessage(MULTIPLE_MULTIBINDING_ANNOTATIONS_ON_METHOD),
                    builder.getSubject(), annotation);
        }
    }

    AnnotationMirror bindingAnnotationMirror = getAnnotationMirror(builder.getSubject(), methodAnnotation)
            .get();
    boolean usesProvidesType = false;
    for (ExecutableElement member : bindingAnnotationMirror.getElementValues().keySet()) {
        usesProvidesType |= member.getSimpleName().contentEquals("type");
    }
    if (usesProvidesType && !multibindingAnnotations.isEmpty()) {
        builder.addError(formatErrorMessage(MULTIBINDING_ANNOTATION_CONFLICTS_WITH_BINDING_ANNOTATION_ENUM),
                builder.getSubject());
    }
}