Example usage for com.google.common.collect ImmutableSetMultimap of

List of usage examples for com.google.common.collect ImmutableSetMultimap of

Introduction

In this page you can find the example usage for com.google.common.collect ImmutableSetMultimap of.

Prototype


@SuppressWarnings("unchecked")
public static <K, V> ImmutableSetMultimap<K, V> of() 

Source Link

Document

Returns the empty multimap.

Usage

From source file:org.glowroot.transaction.model.Transaction.java

public ImmutableSetMultimap<String, String> getCustomAttributes() {
    if (customAttributes == null) {
        return ImmutableSetMultimap.of();
    }/*from   w  w w . j  ava  2  s.c o  m*/
    SetMultimap<String, String> orderedCustomAttributes = TreeMultimap.create(String.CASE_INSENSITIVE_ORDER,
            String.CASE_INSENSITIVE_ORDER);
    synchronized (customAttributes) {
        orderedCustomAttributes.putAll(customAttributes);
    }
    return ImmutableSetMultimap.copyOf(orderedCustomAttributes);
}

From source file:org.apache.sentry.provider.file.SimplePolicyEngine.java

private ImmutableSetMultimap<String, String> parseIni(String database, Ini ini) {
    Ini.Section privilegesSection = ini.getSection(ROLES);
    boolean invalidConfiguration = false;
    if (privilegesSection == null) {
        LOGGER.warn("Section {} empty for {}", ROLES, resourcePath);
        invalidConfiguration = true;/*www  .j  a v  a  2  s.c  o m*/
    }
    Ini.Section groupsSection = ini.getSection(GROUPS);
    if (groupsSection == null) {
        LOGGER.warn("Section {} empty for {}", GROUPS, resourcePath);
        invalidConfiguration = true;
    }
    if (!invalidConfiguration) {
        return parsePermissions(database, privilegesSection, groupsSection);
    }
    return ImmutableSetMultimap.of();
}

From source file:org.glowroot.agent.model.Transaction.java

public ImmutableSetMultimap<String, String> getAttributes() {
    if (attributes == null) {
        return ImmutableSetMultimap.of();
    }/*  w w w.  j  a va  2 s  .c  om*/
    SetMultimap<String, String> orderedAttributes = TreeMultimap.create(String.CASE_INSENSITIVE_ORDER,
            String.CASE_INSENSITIVE_ORDER);
    synchronized (attributes) {
        orderedAttributes.putAll(attributes);
    }
    return ImmutableSetMultimap.copyOf(orderedAttributes);
}

From source file:org.glowroot.agent.impl.Transaction.java

public SetMultimap<String, String> getAttributes() {
    synchronized (attributesLock) {
        if (attributes == null) {
            return ImmutableSetMultimap.of();
        }//  w ww . j a  v a 2 s . com
        SetMultimap<String, String> orderedAttributes = TreeMultimap.create();
        orderedAttributes.putAll(attributes);
        return orderedAttributes;
    }
}

From source file:org.killbill.billing.plugin.simpletax.SimpleTaxPlugin.java

/**
 * Groups the {@linkplain CustomField custom fields} on
 * {@linkplain #INVOICE_ITEM invoice items} by the
 * {@linkplain Invoice#getId() identifier} of their related
 * {@linkplain Invoice invoices}./*  w  ww .j  a v  a2 s.c  o m*/
 *
 * @param account
 *            The account to consider
 * @param allInvoices
 *            The collection of all invoices for the given account.
 * @param tenantCtx
 *            The context in which this code is running.
 * @return A new immutable multi-map containing the custom fields on all
 *         invoice items of the given account, grouped by the identifier of
 *         their relate invoice. Never {@code null}, and guaranteed not
 *         having any {@code null} elements.
 */
private SetMultimap<UUID, CustomField> taxFieldsOfInvoices(Account account, Set<Invoice> allInvoices,
        TenantContext tenantCtx) {
    CustomFieldUserApi customFieldsService = services().getCustomFieldUserApi();
    List<CustomField> allCustomFields = customFieldsService.getCustomFieldsForAccountType(account.getId(),
            INVOICE_ITEM, tenantCtx);
    if ((allCustomFields == null) || allCustomFields.isEmpty()) {
        return ImmutableSetMultimap.of();
    }

    Map<UUID, Invoice> invoiceOfItem = newHashMap();
    for (Invoice invoice : allInvoices) {
        for (InvoiceItem item : invoice.getInvoiceItems()) {
            invoiceOfItem.put(item.getId(), invoice);
        }
    }

    ImmutableSetMultimap.Builder<UUID, CustomField> taxFieldsOfInvoice = ImmutableSetMultimap.builder();
    for (CustomField field : allCustomFields) {
        if (TAX_CODES_FIELD_NAME.equals(field.getFieldName())) {
            Invoice invoice = invoiceOfItem.get(field.getObjectId());
            taxFieldsOfInvoice.put(invoice.getId(), field);
        }
    }
    return taxFieldsOfInvoice.build();
}

From source file:org.opendaylight.groupbasedpolicy.renderer.ofoverlay.arp.ArpTasker.java

private SetMultimap<Node, Pair<InstanceIdentifier<NodeConnector>, MacAddress>> readNodesWithExternalIfaces(
        ReadTransaction rTx) {//from   w ww . ja  v  a 2s .  c  o m
    Optional<Nodes> potentialNodes = DataStoreHelper.readFromDs(LogicalDatastoreType.CONFIGURATION,
            InstanceIdentifier.builder(Nodes.class).build(), rTx);
    if (!potentialNodes.isPresent() || potentialNodes.get().getNode() == null) {
        return ImmutableSetMultimap.of();
    }
    List<Node> nodes = potentialNodes.get().getNode();
    SetMultimap<Node, Pair<InstanceIdentifier<NodeConnector>, MacAddress>> extIfacesByNode = HashMultimap
            .create();
    for (Node node : nodes) {
        OfOverlayNodeConfig ofOverlayNode = node.getAugmentation(OfOverlayNodeConfig.class);
        if (ofOverlayNode != null) {
            List<ExternalInterfaces> externalIfaces = ofOverlayNode.getExternalInterfaces();
            if (externalIfaces != null) {
                for (ExternalInterfaces extIface : externalIfaces) {
                    NodeConnectorId externalNc = extIface.getNodeConnectorId();
                    InstanceIdentifier<NodeConnector> extNcIid = InstanceIdentifier.builder(Nodes.class)
                            .child(Node.class, node.getKey())
                            .child(NodeConnector.class, new NodeConnectorKey(externalNc)).build();
                    Optional<NodeConnector> potentialExtNcFromOper = DataStoreHelper
                            .readFromDs(LogicalDatastoreType.OPERATIONAL, extNcIid, rTx);
                    if (!potentialExtNcFromOper.isPresent()) {
                        LOG.debug("Node connector {} does not exit in OPER DS. Node from CONF: {}",
                                externalNc.getValue(), node);
                        continue;
                    }
                    FlowCapableNodeConnector externalFcNc = potentialExtNcFromOper.get()
                            .getAugmentation(FlowCapableNodeConnector.class);
                    if (externalFcNc == null || externalFcNc.getHardwareAddress() == null) {
                        LOG.debug("Hardware address does not exist on node connector {}",
                                externalNc.getValue());
                        LOG.trace("Node connector from OPER DS {}", potentialExtNcFromOper.get());
                        continue;
                    }
                    extIfacesByNode.put(node, new ImmutablePair<>(extNcIid, externalFcNc.getHardwareAddress()));
                }
            }
        }
    }
    return extIfacesByNode;
}

From source file:com.facebook.buck.features.apple.project.WorkspaceAndProjectGenerator.java

private GenerationResult generateProjectForDirectory(Map<Path, ProjectGenerator> projectGenerators,
        Cell projectCell, Path projectDirectory, ImmutableSet<BuildTarget> rules, boolean isMainProject,
        ImmutableSet<BuildTarget> targetsInRequiredProjects) throws IOException {
    boolean shouldGenerateProjects = false;
    ProjectGenerator generator;/*  w  w w. j av a  2  s.com*/
    synchronized (projectGenerators) {
        generator = projectGenerators.get(projectDirectory);
        if (generator != null) {
            LOG.debug("Already generated project for target %s, skipping", projectDirectory);
        } else {
            LOG.debug("Generating project for directory %s with targets %s", projectDirectory, rules);
            String projectName;
            if (projectDirectory.getFileName().toString().equals("")) {
                // If we're generating a project in the root directory, use a generic name.
                projectName = "Project";
            } else {
                // Otherwise, name the project the same thing as the directory we're in.
                projectName = projectDirectory.getFileName().toString();
            }
            generator = new ProjectGenerator(xcodeDescriptions, projectGraph, dependenciesCache,
                    projGenerationStateCache, rules, projectCell, projectDirectory, projectName, buildFileName,
                    projectGeneratorOptions, ruleKeyConfiguration, isMainProject,
                    workspaceArguments.getSrcTarget(), targetsInRequiredProjects, focusModules,
                    defaultCxxPlatform, appleCxxFlavors, graphBuilderForNode, buckEventBus, halideBuckConfig,
                    cxxBuckConfig, appleConfig, swiftBuckConfig, sharedLibraryToBundle);
            projectGenerators.put(projectDirectory, generator);
            shouldGenerateProjects = true;
        }
    }

    ImmutableSet<BuildTarget> requiredBuildTargets = ImmutableSet.of();
    ImmutableMap<BuildTarget, PBXTarget> buildTargetToGeneratedTargetMap = ImmutableMap.of();
    ImmutableSetMultimap<PBXProject, PBXTarget> generatedProjectToGeneratedTargets = ImmutableSetMultimap.of();
    if (shouldGenerateProjects) {
        generator.createXcodeProjects();
    }
    if (generator.isProjectGenerated()) {
        requiredBuildTargets = generator.getRequiredBuildTargets();
        buildTargetToGeneratedTargetMap = generator.getBuildTargetToGeneratedTargetMap();
        generatedProjectToGeneratedTargets = generator.getGeneratedProjectToGeneratedTargets();
    }

    return GenerationResult.of(generator.getProjectPath(), generator.isProjectGenerated(), requiredBuildTargets,
            generator.getXcconfigPaths(), generator.getFilesToCopyInXcode(), buildTargetToGeneratedTargetMap,
            generatedProjectToGeneratedTargets);
}