Example usage for com.google.common.collect Maps newLinkedHashMap

List of usage examples for com.google.common.collect Maps newLinkedHashMap

Introduction

In this page you can find the example usage for com.google.common.collect Maps newLinkedHashMap.

Prototype

public static <K, V> LinkedHashMap<K, V> newLinkedHashMap() 

Source Link

Document

Creates a mutable, empty, insertion-ordered LinkedHashMap instance.

Usage

From source file:com.chiorichan.factory.ScriptBinding.java

public Map<String, Object> getVariables() {
    if (variables == null)
        variables = Maps.newLinkedHashMap();
    return variables;
}

From source file:org.sonar.flex.checks.DuplicateSwitchCaseImplementationCheck.java

@Override
public void visitNode(AstNode astNode) {
    Map<AstNode, List<Token>> cases = Maps.newLinkedHashMap();

    for (AstNode caseElement : astNode.getChildren(FlexGrammar.CASE_ELEMENT)) {
        AstNode caseLabel = caseElement.getLastChild(FlexGrammar.CASE_LABEL);
        List<Token> tokens = getCaseImplementationTokens(caseElement);

        if (!tokens.isEmpty()) {
            AstNode duplicatedCase = getDuplicatedCase(cases, tokens);

            if (duplicatedCase != null) {
                getContext().createLineViolation(this,
                        "Either merge this case with the identical one on line \"{0}\" or change one of the implementations.",
                        caseElement, duplicatedCase.getTokenLine());
            } else {
                cases.put(caseLabel, tokens);
            }//from   ww  w  . jav a  2s. c  om
        }
    }
}

From source file:dagger2.internal.codegen.writer.MethodWriter.java

MethodWriter(TypeName returnType, String name) {
    this.returnType = returnType;
    this.name = name;
    this.parameterWriters = Maps.newLinkedHashMap();
    this.typeParameters = Lists.newArrayList();
    this.body = Optional.absent();
}

From source file:com.google.caja.ancillary.opt.EnvironmentData.java

public EnvironmentData(Map<? extends String, ?> data) throws ParseException {
    this.data = Maps.newLinkedHashMap();
    for (Map.Entry<? extends String, ?> e : data.entrySet()) {
        this.data.put(normJsQuiet(e.getKey()), e.getValue());
    }//ww  w.  ja  va2s. com
}

From source file:org.auraframework.test.mock.MockModelDef.java

public MockModelDef(DefDescriptor<ModelDef> descriptor, Set<ValueDef> members, List<Answer<Model>> instances) {
    super(descriptor);
    this.members = Maps.newLinkedHashMap();
    if (members != null) {
        for (ValueDef val : members) {
            this.members.put(val.getName(), val);
        }//from w w w  . jav a  2 s  .co m
    }
    this.instances = instances != null ? Lists.newLinkedList(instances) : Lists.<Answer<Model>>newLinkedList();
}

From source file:org.n52.matlab.connector.MatlabResult.java

/**
 * Creates a new <code>MatlabResult</code> instance.
 *
 * @param id the request id//from   www .  j a v  a 2 s  .  co m
 */
public MatlabResult(long id) {
    this.results = Maps.newLinkedHashMap();
    this.id = id;
}

From source file:com.facebook.buck.cxx.AbstractCxxHeaders.java

public static CxxHeaders concat(Iterable<CxxHeaders> headerGroup) throws ConflictingHeadersException {

    Map<Path, SourcePath> nameToPathMap = Maps.newLinkedHashMap();
    Map<Path, SourcePath> fullNameToPathMap = Maps.newLinkedHashMap();

    for (CxxHeaders headers : headerGroup) {
        addAllEntriesToIncludeMap(nameToPathMap, headers.getNameToPathMap());
        addAllEntriesToIncludeMap(fullNameToPathMap, headers.getFullNameToPathMap());
    }//  w  w  w.  j  a  v  a 2  s.co  m

    return CxxHeaders.builder().setNameToPathMap(nameToPathMap).setFullNameToPathMap(fullNameToPathMap).build();
}

From source file:org.carrot2.util.attribute.BindableDescriptorBuilder.java

/**
 * Internal implementation of descriptor building.
 *//*from   ww  w .ja  va  2 s  .co m*/
private static BindableDescriptor buildDescriptor(Object initializedInstance, Set<Object> processedInstances) {
    final Class<?> clazz = initializedInstance.getClass();
    if (clazz.getAnnotation(Bindable.class) == null) {
        throw new IllegalArgumentException("Provided instance must be @Bindable");
    }

    if (!processedInstances.add(initializedInstance)) {
        throw new UnsupportedOperationException("Circular references are not supported");
    }

    // Load metadata
    final BindableMetadata bindableMetadata = BindableMetadata.forClassWithParents(clazz);

    // Build descriptors for direct attributes
    final Map<String, AttributeDescriptor> attributeDescriptors = buildAttributeDescriptors(initializedInstance,
            bindableMetadata);

    // Build descriptors for nested bindables
    final Map<Field, BindableDescriptor> bindableDescriptors = Maps.newLinkedHashMap();

    final Collection<Field> fieldsFromBindableHierarchy = BindableUtils.getFieldsFromBindableHierarchy(clazz);
    for (final Field field : fieldsFromBindableHierarchy) {
        // Get class of runtime value
        Object fieldValue = null;
        try {
            field.setAccessible(true);
            fieldValue = field.get(initializedInstance);
        } catch (final Exception e) {
            throw new RuntimeException("Could not retrieve default value of field: "
                    + field.getClass().getName() + "#" + field.getName());
        }

        // Descend only for non-null values
        if (fieldValue != null && fieldValue.getClass().getAnnotation(Bindable.class) != null) {
            bindableDescriptors.put(field, buildDescriptor(fieldValue, processedInstances));
        }
    }

    return new BindableDescriptor(clazz, bindableMetadata, bindableDescriptors, attributeDescriptors);
}

From source file:com.comphenix.protocol.compat.netty.independent.NettyProtocolRegistry.java

@Override
protected synchronized void initialize() {
    Object[] protocols = enumProtocol.getEnumConstants();

    // ID to Packet class maps
    Map<Object, Map<Integer, Class<?>>> serverMaps = Maps.newLinkedHashMap();
    Map<Object, Map<Integer, Class<?>>> clientMaps = Maps.newLinkedHashMap();

    Register result = new Register();
    StructureModifier<Object> modifier = null;

    // Iterate through the protocols
    for (Object protocol : protocols) {
        if (modifier == null)
            modifier = new StructureModifier<Object>(protocol.getClass().getSuperclass(), false);
        StructureModifier<Map<Object, Map<Integer, Class<?>>>> maps = modifier.withTarget(protocol)
                .withType(Map.class);
        for (Entry<Object, Map<Integer, Class<?>>> entry : maps.read(0).entrySet()) {
            String direction = entry.getKey().toString();
            if (direction.contains("CLIENTBOUND")) { // Sent by Server
                serverMaps.put(protocol, entry.getValue());
            } else if (direction.contains("SERVERBOUND")) { // Sent by Client
                clientMaps.put(protocol, entry.getValue());
            }/*  w  ww . j av  a  2s  . co  m*/
        }
    }

    // Maps we have to occationally check have changed
    for (Map<Integer, Class<?>> map : serverMaps.values()) {
        result.containers.add(new MapContainer(map));
    }

    for (Map<Integer, Class<?>> map : clientMaps.values()) {
        result.containers.add(new MapContainer(map));
    }

    for (int i = 0; i < protocols.length; i++) {
        Object protocol = protocols[i];
        Enum<?> enumProtocol = (Enum<?>) protocol;
        Protocol equivalent = Protocol.fromVanilla(enumProtocol);

        // Associate known types
        if (serverMaps.containsKey(protocol))
            associatePackets(result, serverMaps.get(protocol), equivalent, Sender.SERVER);
        if (clientMaps.containsKey(protocol))
            associatePackets(result, clientMaps.get(protocol), equivalent, Sender.CLIENT);
    }

    // Exchange (thread safe, as we have only one writer)
    this.register = result;
}

From source file:com.google.jstestdriver.idea.ui.CapturedBrowsersPanel.java

public CapturedBrowsersPanel() {
    try {/* w  w w.  ja va  2s .  c  o  m*/
        myBrowserLabelByNameMap = Maps.newLinkedHashMap(); // order is important
        addBrowser("Chrome", "Chrome.png");
        addBrowser("Microsoft Internet Explorer", "IE.png");
        addBrowser("Firefox", "Firefox.png");
        addBrowser("Opera", "Opera.png");
        addBrowser("Safari", "Safari.png");
    } catch (IOException e) {
        throw new RuntimeException();
    }

    setLayout(new BoxLayout(this, BoxLayout.X_AXIS));

    Collection<BrowserLabel> browserLabels = myBrowserLabelByNameMap.values();
    for (BrowserLabel browserLabel : browserLabels) {
        add(browserLabel);
    }

    Icon icon = browserLabels.iterator().next().getBrowserIcon().getColorIcon();
    Dimension minimumSize = new Dimension(icon.getIconWidth() * browserLabels.size(), icon.getIconHeight());
    setMinimumSize(minimumSize);
    setPreferredSize(minimumSize);
}