Example usage for com.google.common.collect BiMap putAll

List of usage examples for com.google.common.collect BiMap putAll

Introduction

In this page you can find the example usage for com.google.common.collect BiMap putAll.

Prototype

@Override
void putAll(Map<? extends K, ? extends V> map);

Source Link

Document

Warning: the results of calling this method may vary depending on the iteration order of map .

Usage

From source file:ca.wumbo.wdl.Start.java

/**
 * Takes the info in a command line parser and pushes in the game.
 * /*ww  w. j  av a 2  s.c  o m*/
 * @param clp
 *       The command line parser.
 * 
 * @throws SQLException
 *       If there is any SQL errors.
 *  
 * @throws JAXBException
 *      If there is a parsing error.
 *  
 * @throws IOException 
 *       If an IO error occured or a file couldn't be found. This works for
 *       both the XML and log files currently.
 * 
 * @throws MissingGameInDatabaseException
 *       If the game is not in the database.
 * 
 * @throws RuntimeException
 *       If some unexpected exception occurs while closing.
 */
private static void pushGameLogToDatabase(CommandLineParser clp)
        throws JAXBException, SQLException, IOException, MissingGameInDatabaseException {
    assert clp != null;

    Parser parser = new Parser();

    log.trace("Reading in log files and map IDs.");
    String logName = "";
    try {
        for (Pair<String, Integer> fileAndMap : clp.getLogFiles()) {
            logName = fileAndMap.getFirst();
            int mapId = fileAndMap.getSecond();
            log.debug("Reading in {} (id = {}).", logName, mapId);
            parser.addRoundPath(logName, mapId);
        }
    } catch (IOException e) {
        log.error("Error reading the a log file: {}", logName);
        throw e;
    }

    log.trace("Connecting to database to push in log information.");
    try (LogEventSubmitter connection = new LogEventSubmitter()) {
        int dbGameId = clp.getGameId();
        int redTeamId = clp.getRedTeamId();
        int blueTeamId = clp.getBlueTeamId();
        BiMap<Integer, String> idToPlayerMap = HashBiMap.create();
        idToPlayerMap.putAll(clp.getPlayers());
        log.debug("Pushing in game ID = {} for (red ID = {}, blue ID = {}).", dbGameId, redTeamId, blueTeamId);
        log.trace("PlayerMap = {}", idToPlayerMap.toString());
        connection.pushEventsToDatabase(dbGameId, parser, idToPlayerMap, redTeamId, blueTeamId);
    } catch (FileNotFoundException e) {
        throw new IOException(e);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}

From source file:org.nuxeo.ecm.platform.shibboleth.service.ShibbolethAuthenticationServiceImpl.java

@Override
public BiMap<String, String> getUserMetadata() {
    BiMap<String, String> biMap = HashBiMap.create();
    biMap.putAll(config.getFieldMapping());
    return biMap;
}

From source file:seeit3d.base.ui.ide.view.MappingViewComposite.java

private BiMap<MetricCalculator, VisualProperty> buildCurrentMapping(List<Container> currentContainers) {
    if (!currentContainers.isEmpty()) {
        BiMap<MetricCalculator, VisualProperty> mapping = HashBiMap.create();
        mapping.putAll(currentContainers.get(0).getPropertiesMap());
        for (int i = 1; i < currentContainers.size(); i++) {
            Container container = currentContainers.get(i);
            if (!mapping.equals(container.getPropertiesMap())) {
                return HashBiMap.create();
            }// ww w.ja va 2  s .  co  m
        }
        return mapping;
    }
    return HashBiMap.create();

}

From source file:org.sonatype.plugin.nexus.testenvironment.AbstractEnvironmentMojo.java

@SuppressWarnings("unchecked")
private void validateStaticPorts() throws MojoExecutionException, MojoFailureException {
    if (this.staticPorts != null) {
        try {/*  w ww  . j  a v  a2 s. c o m*/
            @SuppressWarnings("rawtypes")
            BiMap staticPortMap = HashBiMap.create(this.staticPorts.size());
            staticPortMap = MapConstraints.constrainedBiMap(staticPortMap, MapConstraints.notNull());
            staticPortMap.putAll(this.staticPorts);
            this.staticPorts = staticPortMap;
        } catch (NullPointerException npe) {
            throw new MojoExecutionException("Port names and values must not be null.", npe);
        } catch (IllegalArgumentException iae) {
            throw new MojoExecutionException("Port names and values must not be duplicated.", iae);
        }
    }
}

From source file:org.usergrid.management.cassandra.ManagementServiceImpl.java

@Override
public BiMap<UUID, String> getApplicationsForOrganizations(Set<UUID> organizationIds) throws Exception {
    if (organizationIds == null) {
        return null;
    }//  www . jav a  2s  . co m
    BiMap<UUID, String> applications = HashBiMap.create();
    for (UUID organizationId : organizationIds) {
        BiMap<UUID, String> organizationApplications = getApplicationsForOrganization(organizationId);
        applications.putAll(organizationApplications);
    }
    return applications;
}

From source file:de.monticore.genericgraphics.view.layout.kieler.MCDiagramLayoutManager.java

/**
 * <p>/*from w w  w  . j ava  2  s. c o  m*/
 * Add all connections to the mapping.
 * </p>
 * <p>
 * Therefore iterate through all added IMCEditParts and check for outgoing
 * connections.
 * </p>
 * 
 * @param mapping The {@link LayoutMapping} to add all connections to.
 */
private void addAllConnections(LayoutMapping<IMCEditPart> mapping) {
    BiMap<KGraphElement, IMCEditPart> graphMap = mapping.getGraphMap();
    Map<KEdge, IMCEditPart> newCons = new HashMap<KEdge, IMCEditPart>();

    for (IMCGraphicalEditPart ep : mapping.getProperty(CONNECTIONS)) {
        // add all source connections
        for (Object c : ep.getSourceConnections()) {

            // add connections only, if they have an associated ViewElement
            // check for IMCConnectionEditPart and IMCViewElementEditPart
            // is necessary to ensure that computed bendpoints can be applied
            if (!(c instanceof IMCConnectionEdgeEditPart)) {
                continue;
            }

            IMCConnectionEdgeEditPart cep = (IMCConnectionEdgeEditPart) c;

            // find a proper source node and source port
            KGraphElement sourceElem = null;
            EditPart sourceObj = cep.getSource();
            if (sourceObj instanceof IMCEditPart) {
                sourceElem = graphMap.inverse().get(sourceObj);
            }

            KNode sourceNode = null;
            KPort sourcePort = null;
            if (sourceElem instanceof KNode) {
                sourceNode = (KNode) sourceElem;
            } else if (sourceElem instanceof KPort) {
                sourcePort = (KPort) sourceElem;
                sourceNode = sourcePort.getNode();
            } else {
                continue;
            }

            // find a proper target node and target port
            KGraphElement targetElem = null;
            EditPart targetObj = cep.getTarget();
            if (targetObj instanceof IMCEditPart) {
                targetElem = graphMap.inverse().get(targetObj);
            }

            KNode targetNode = null;
            KPort targetPort = null;
            if (targetElem instanceof KNode) {
                targetNode = (KNode) targetElem;
            } else if (targetElem instanceof KPort) {
                targetPort = (KPort) targetElem;
                targetNode = targetPort.getNode();
            } else {
                continue;
            }

            KEdge edge = KimlUtil.createInitializedEdge();

            if (sourceNode == null || targetNode == null) {
                System.err.println(
                        "MCDLM> source: " + sourceNode + " target: " + targetNode + "! Skip this connection!");
                continue;
            }

            // set source and target
            edge.setSource(sourceNode);
            if (sourcePort != null) {
                edge.setSourcePort(sourcePort);
            }
            edge.setTarget(targetNode);
            if (targetPort != null) {
                edge.setTargetPort(targetPort);
            }

            newCons.put(edge, cep);

            // store the current coordinates of the edge
            KEdgeLayout edgeLayout = edge.getData(KEdgeLayout.class);
            setKEdgeLayout(edgeLayout, cep.getViewElement(), ((PolylineConnection) cep.getFigure()));

            if (cep instanceof IConnectionType) {
                IConnectionType.Connection_Type type = ((IConnectionType) cep).getConnectionType();
                if (type != null) {
                    switch (type) {
                    case ASSOCIATION:
                        edgeLayout.setProperty(LayoutOptions.EDGE_TYPE, EdgeType.ASSOCIATION);
                        break;
                    case DEPENDENCY:
                        edgeLayout.setProperty(LayoutOptions.EDGE_TYPE, EdgeType.DEPENDENCY);
                        break;
                    case GENERALIZATION:
                        edgeLayout.setProperty(LayoutOptions.EDGE_TYPE, EdgeType.GENERALIZATION);
                        break;
                    default:
                        edgeLayout.setProperty(LayoutOptions.EDGE_TYPE, EdgeType.ASSOCIATION);
                        break;
                    }
                } else {
                    edgeLayout.setProperty(LayoutOptions.EDGE_TYPE, EdgeType.ASSOCIATION);
                }
            }
            // the modification flag must initially be false
            ((KEdgeLayoutImpl) edgeLayout).resetModificationFlag();

            // check for labels to add
            addAllLabels(mapping, cep, edge);
        } // end-for souceConnections
    } // end-for editparts

    // add the connections to the graphMap
    graphMap.putAll(newCons);
}