Example usage for com.google.common.collect ArrayListMultimap create

List of usage examples for com.google.common.collect ArrayListMultimap create

Introduction

In this page you can find the example usage for com.google.common.collect ArrayListMultimap create.

Prototype

public static <K, V> ArrayListMultimap<K, V> create() 

Source Link

Document

Creates a new, empty ArrayListMultimap with the default initial capacities.

Usage

From source file:fr.jcgay.maven.plugin.buildplan.display.AbstractTableDescriptor.java

protected static Map<TableColumn, Integer> findMaxSize(Collection<MojoExecution> executions,
        TableColumn... columns) {

    Map<TableColumn, Integer> result = new HashMap<TableColumn, Integer>();

    Multimap<TableColumn, Integer> count = ArrayListMultimap.create();
    for (MojoExecution execution : executions) {
        for (TableColumn column : columns) {
            switch (column) {
            case ARTIFACT_ID:
                count.put(column, safeLength(execution.getArtifactId()));
                break;
            case EXECUTION_ID:
                count.put(column, safeLength(execution.getExecutionId()));
                break;
            case GOAL:
                count.put(column, safeLength(execution.getGoal()));
                break;
            case PHASE:
                MojoDescriptor mojoDescriptor = execution.getMojoDescriptor();
                if (mojoDescriptor != null && mojoDescriptor.getPhase() != null) {
                    count.put(column, safeLength(mojoDescriptor.getPhase()));
                } else {
                    count.put(column, safeLength(execution.getLifecyclePhase()));
                }/*from ww w.  jav a 2 s . co  m*/
            }
        }
    }
    for (TableColumn column : TableColumn.values()) {
        count.put(column, column.title().length());
    }

    for (TableColumn key : count.keySet()) {
        result.put(key, Collections.max(count.get(key)));
    }

    return result;
}

From source file:scoutdoc.main.check.CheckstyleFileWriter.java

public static void write(List<Check> list, PrintWriter w) {
    w.println(XML_VERSION);/*w w  w  .  j a  v  a 2 s.  c o m*/
    w.println(CHECKSTYLE_OPEN);

    Multimap<String, Check> multimap = ArrayListMultimap.create();

    for (Check check : list) {
        String filePath = PageUtility.toFile(check.getPage()).getAbsolutePath();
        multimap.put(filePath, check);
    }

    for (String file : multimap.keySet()) {
        w.println("<file name=\"" + file + "\">");
        for (Check check : multimap.get(file)) {
            w.print("<error");
            w.print(" line=\"" + check.getLine() + "\"");
            w.print(" column=\"" + check.getColumn() + "\"");
            w.print(" severity=\"" + Objects.firstNonNull(check.getSeverity(), "") + "\"");
            w.print(" message=\"" + Strings.nullToEmpty(check.getMessage()) + "\"");
            w.print(" source=\"" + Strings.nullToEmpty(check.getSource()) + "\"");
            w.println("/>");
        }
        w.println(FILE_CLOSE);
    }
    w.println(CHECKSTYLE_CLOSE);
}

From source file:io.scigraph.services.jersey.MultivaluedMapUtils.java

/***
 * Converts a {@link MultivaluedMap} to a {@link Multimap}.
 * /*from www . j a  v  a  2  s.com*/
 * @param map the original map
 * @param separator an optional separator to further split the values in the map
 * @return the new multimap
 */
public static Multimap<String, Object> multivaluedMapToMultimap(MultivaluedMap<String, String> map,
        Optional<Character> separator) {
    Multimap<String, Object> merged = ArrayListMultimap.create();
    for (Entry<String, List<String>> entry : map.entrySet()) {
        for (String value : entry.getValue()) {
            if (separator.isPresent()) {
                merged.putAll(entry.getKey(), Splitter.on(separator.get()).split(value));
            } else {
                merged.put(entry.getKey(), value);
            }
        }
    }
    return merged;
}

From source file:eu.esdihumboldt.hale.ui.functions.groovy.internal.PathTree.java

/**
 * Create path trees from the given tree paths
 * /*from   ww w  .  ja  v a 2 s.c  o m*/
 * @param paths the tree paths
 * @param startIndex the start index
 * @return the list of path trees, one per different segment on the paths at
 *         the start index
 */
public static List<PathTree> createPathTrees(Iterable<TreePath> paths, int startIndex) {
    // partition paths by segment at index
    ListMultimap<Object, TreePath> partitioned = ArrayListMultimap.create();
    for (TreePath path : paths) {
        if (startIndex < path.getSegmentCount()) {
            partitioned.put(path.getSegment(startIndex), path);
        }
    }

    List<PathTree> result = new ArrayList<>();

    // for each different segment a PathTree must be created
    for (Object segment : partitioned.keySet()) {
        PathTree pt = new PathTree(segment, createPathTrees(partitioned.get(segment), startIndex + 1));
        result.add(pt);
    }

    return result;
}

From source file:org.rf.ide.core.testdata.model.table.RobotExecutableRowView.java

public static <T extends IExecutableStepsHolder<?>> RobotExecutableRowView buildView(
        final RobotExecutableRow<T> execRowOne) {
    final ListMultimap<RobotToken, RobotToken> specialTokens = ArrayListMultimap.create();

    final T parent = execRowOne.getParent();
    if (parent != null) {
        final AModelElement<? extends ARobotSectionTable> holder = parent.getHolder();
        if (holder != null) {
            final ARobotSectionTable table = holder.getParent();
            if (table != null) {
                final RobotFile modelFile = table.getParent();
                final List<RobotLine> fileContent = modelFile.getFileContent();

                final List<RobotToken> rowElements = execRowOne.getElementTokens();
                for (final RobotToken token : rowElements) {
                    final List<IRobotTokenType> types = token.getTypes();
                    if (types.contains(RobotTokenType.START_HASH_COMMENT)
                            || types.contains(RobotTokenType.COMMENT_CONTINUE)) {
                        break;
                    } else if (types.contains(RobotTokenType.VARIABLE_USAGE)) {
                        extractAdditionalAssignmentAndPrettyAlignForCurrentToken(specialTokens, modelFile,
                                fileContent, token);
                    }/*from w  w  w.ja  v  a2  s .com*/
                }
            }
        }
    }

    return new RobotExecutableRowView(specialTokens);
}

From source file:mine.suggestions.SuggestionMap.java

public SuggestionMap() {
    this.multiMap = ArrayListMultimap.create();
}

From source file:org.geoserver.script.wfs.TransactionDetail.java

public TransactionDetail() {
    entries = ArrayListMultimap.create();
}

From source file:google.registry.testing.UriParameters.java

/**
 * Constructs a new parameter map populated with parameters parsed from the specified query string
 * using the specified encoding.//w  w  w  .j a  va  2s  . c om
 *
 * @param query the query string, e.g., {@code "q=flowers&n=20"}
 * @return a mutable parameter map representing the query string
 */
public static ListMultimap<String, String> parse(String query) {
    checkNotNull(query);
    ListMultimap<String, String> map = ArrayListMultimap.create();
    if (!query.isEmpty()) {
        int start = 0;
        while (start <= query.length()) {
            // Find the end of the current parameter.
            int ampersandIndex = query.indexOf('&', start);
            if (ampersandIndex == -1) {
                ampersandIndex = query.length();
            }
            int equalsIndex = query.indexOf('=', start);
            if (equalsIndex > ampersandIndex) {
                // Equal is in the next parameter, so this parameter has no value.
                equalsIndex = -1;
            }
            int paramNameEndIndex = (equalsIndex == -1) ? ampersandIndex : equalsIndex;
            String name = decodeString(query, start, paramNameEndIndex);
            String value = (equalsIndex == -1) ? "" : decodeString(query, equalsIndex + 1, ampersandIndex);
            map.put(name, value);
            start = ampersandIndex + 1;
        }
    }
    return map;
}

From source file:org.rf.ide.core.testdata.model.table.variables.names.VariableNamesSupport.java

public static Multimap<String, RobotToken> extractUnifiedVariables(final List<RobotToken> assignments,
        final VariableExtractor extractor, final String fileName) {
    final Multimap<String, RobotToken> vars = ArrayListMultimap.create();
    for (final RobotToken token : assignments) {
        final MappingResult mappingResult = extractor.extract(token, fileName);
        for (final VariableDeclaration variableDeclaration : mappingResult.getCorrectVariables()) {
            vars.put(extractUnifiedVariableName(variableDeclaration.asToken().getText()),
                    variableDeclaration.asToken());
        }//from  w w w .  jav  a 2  s .  c  o m
    }
    return vars;
}

From source file:com.sergiu.practice.discography.dao.Discography.java

@PostConstruct
void init() {//  w ww.j a v a 2  s.com
    discographyStore = ArrayListMultimap.create();
    // Add init data
    Song a = new Song("Innuendo");
    Song b = new Song("I'm Going Slightly Mad");
    Song c = new Song("Headlong");
    Song d = new Song("I Can't Live With You");
    Song e = new Song("Ride The Wild Wind");
    Song f = new Song("All God's People");
    Song g = new Song("These Are The Days Of Our Lives");
    Song h = new Song("Delilah");
    Song i = new Song("Don't Try So Hard");
    Song j = new Song("The Hitman");
    Song k = new Song("Bijou");
    Song l = new Song("The Show Must Go On");

    Album album = new Album("Innuendo", "1991");

    Artist artist = new Artist("Queen");

}