Example usage for com.google.common.collect LinkedListMultimap entries

List of usage examples for com.google.common.collect LinkedListMultimap entries

Introduction

In this page you can find the example usage for com.google.common.collect LinkedListMultimap entries.

Prototype

@Override
public List<Entry<K, V>> entries() 

Source Link

Document

The iterator generated by the returned collection traverses the entries in the order they were added to the multimap.

Usage

From source file:be.neutrinet.ispng.openvpn.ManagementInterface.java

public void authorizeClient(int id, int kid, LinkedListMultimap<String, String> options) {
    String authorize = "client-auth " + id + ' ' + kid + '\n';
    try {//from w  ww .  j  av  a 2 s .  com
        writeLine(authorize);
        for (Map.Entry<String, String> entry : options.entries()) {
            writeLine(entry.getKey() + (entry.getValue() != null ? " " + entry.getValue() : "") + '\n');
        }
        writeLine("END\n");
    } catch (IOException ex) {
        Logger.getLogger(getClass()).error("Failed to write command", ex);
    }
}

From source file:org.eclipse.xtext.idea.formatting.DefaultXtextBlock.java

protected List<Block> group(final Iterable<Block> blocks) {
    LinkedList<Block> _xblockexpression = null;
    {//from w w w  . ja v a 2 s  . co  m
        final LinkedListMultimap<BracePair, Integer> openingBlockIndex = LinkedListMultimap
                .<BracePair, Integer>create();
        final LinkedList<Block> stack = CollectionLiterals.<Block>newLinkedList();
        for (final Block block : blocks) {
            {
                boolean _isOpening = this._blockExtension.isOpening(block);
                if (_isOpening) {
                    final BracePair bracePair = this._blockExtension.getBracePairForOpeningBrace(block);
                    int _size = stack.size();
                    openingBlockIndex.put(bracePair, Integer.valueOf(_size));
                }
                boolean _isClosing = this._blockExtension.isClosing(block);
                if (_isClosing) {
                    final BracePair bracePair_1 = this._blockExtension.getBracePairForClosingBrace(block);
                    List<Integer> _get = openingBlockIndex.get(bracePair_1);
                    final Integer index = IterableExtensions.<Integer>last(_get);
                    boolean _notEquals = (!Objects.equal(index, null));
                    if (_notEquals) {
                        openingBlockIndex.remove(bracePair_1, index);
                        this.group(stack, index, bracePair_1, block);
                    }
                }
                stack.addLast(block);
            }
        }
        List<Map.Entry<BracePair, Integer>> _entries = openingBlockIndex.entries();
        final Comparator<Map.Entry<BracePair, Integer>> _function = (Map.Entry<BracePair, Integer> $0,
                Map.Entry<BracePair, Integer> $1) -> {
            Integer _value = $0.getValue();
            Integer _value_1 = $1.getValue();
            return _value.compareTo(_value_1);
        };
        List<Map.Entry<BracePair, Integer>> _sortWith = IterableExtensions.<Map.Entry<BracePair, Integer>>sortWith(
                _entries, _function);
        List<Map.Entry<BracePair, Integer>> _reverse = ListExtensions.<Map.Entry<BracePair, Integer>>reverse(
                _sortWith);
        for (final Map.Entry<BracePair, Integer> entry : _reverse) {
            Integer _value = entry.getValue();
            BracePair _key = entry.getKey();
            this.group(stack, _value, _key, null);
        }
        _xblockexpression = stack;
    }
    return _xblockexpression;
}