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:org.eclipse.xtext.xtext.ecoreInference.EClassifierInfos.java

public EClassifierInfos(Grammar grammar) {
    this.grammar = grammar;
    infoMap = Maps.newLinkedHashMap();
    parents = Lists.newArrayList();
}

From source file:com.yahoo.yqlplus.engine.internal.generate.StructGenerator.java

public StructGenerator(String name, ASMClassSource environment) {
    super(name, StructBase.class, environment);
    this.fields = Maps.newLinkedHashMap();
    this.propertyList = Lists.newArrayList();
}

From source file:brooklyn.event.feed.jmx.JmxValueFunctions.java

public static Map<String, Object> compositeDataToMap(CompositeData data) {
    Map<String, Object> result = Maps.newLinkedHashMap();
    for (String key : data.getCompositeType().keySet()) {
        Object old = result.put(key, data.get(key));
        if (old != null) {
            log.warn("compositeDataToMap has overwritten key {}", key);
        }//  w w  w.  j  a  va 2  s  .  c  o m
    }
    return result;
}

From source file:org.summer.dsl.xbase.validation.XbaseConfigurableIssueCodes.java

public XbaseConfigurableIssueCodes() {
    final Map<String, PreferenceKey> map = Maps.newLinkedHashMap();
    initialize(new IAcceptor<PreferenceKey>() {

        public void accept(PreferenceKey prefKey) {
            map.put(prefKey.getId(), prefKey);
        }/* www .  j  av a 2  s  .  com*/
    });
    this.issueCodes = ImmutableMap.copyOf(map);
}

From source file:acromusashi.stream.entity.StreamMessage.java

/**
 * Add field to message body./*from w  ww .  jav a 2s .  c o  m*/
 *
 * @param key key
 * @param value value
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
public void addField(String key, Object value) {
    if (this.body == null || Map.class.isAssignableFrom(this.body.getClass()) == false) {
        this.body = Maps.newLinkedHashMap();
    }

    ((Map) this.body).put(key, value);
}

From source file:cc.recommenders.evaluation.evaluators.DefF1Evaluator.java

@Override
public Map<DefinitionSiteKind, Boxplot> getResults() {

    Map<DefinitionSiteKind, Boxplot> out = Maps.newLinkedHashMap();

    for (DefinitionSiteKind type : results.keySet()) {
        Boxplot boxplot = results.get(type).getBoxplot();
        out.put(type, boxplot);/*ww w  .  j  a  v a 2s  .  co m*/
    }

    return out;
}

From source file:com.olacabs.fabric.compute.sources.kafka.impl.KafkaBasedOffsetSource.java

@Override
public void saveOffset(String topicArg, int partition, long offset) throws Exception {
    while (true) {
        long now = System.currentTimeMillis();
        Map<TopicAndPartition, OffsetAndMetadata> offsets = Maps.newLinkedHashMap();
        offsets.put(new TopicAndPartition(topicArg, partition), new OffsetAndMetadata(100L, "", now));
        OffsetCommitRequest commitRequest = new OffsetCommitRequest(groupId(), offsets, 0, //TODO CORRELATION ID.
                HostUtils.hostname(), (short) 1 /* version */); // version 1 and above commit to Kafka, version 0 commits to ZooKeeper
        try {//from   w  ww  . ja  v a2s  .  co m
            channel.send(commitRequest.underlying());
            OffsetCommitResponse commitResponse = OffsetCommitResponse.readFrom(channel.receive().buffer());
            if (commitResponse.hasError()) {
                for (Object partitionErrorCodeRaw : commitResponse.errors().values()) {
                    short partitionErrorCode = (Short) partitionErrorCodeRaw;
                    if (partitionErrorCode == OffsetMetadataTooLargeCode()) {
                        // You must reduce the size of the metadata if you wish to retry
                        //TODO SAVE META MAP
                        LOGGER.debug("TODO::SAVE META MAP");
                    } else if (partitionErrorCode == ErrorMapping.NotCoordinatorForConsumerCode()
                            || partitionErrorCode == ErrorMapping.ConsumerCoordinatorNotAvailableCode()) {
                        channel.disconnect();
                        reconnect();
                    } else {
                        //TODO log and retry the commit
                        LOGGER.debug("TODO log and retry the commit");
                    }
                }
            } else {
                return;
            }
        } catch (Exception ioe) {
            channel.disconnect();
            reconnect();
        }
    }
}

From source file:com.yahoo.yqlplus.engine.internal.bytecode.ClassAdapterGenerator.java

private void generateGetProperty(TypeWidget targetType, final PropertyAdapter propertyAdapter) {
    MethodGenerator method = createStaticMethod("getProperty");
    method.setReturnType(AnyTypeWidget.getInstance());
    final BytecodeExpression targetExpr = method.addArgument("target", targetType).read();
    final BytecodeExpression propertyName = method.addArgument("property", BaseTypeAdapter.STRING).read();
    method.add(new BytecodeSequence() {
        @Override/*from  w  w w  .ja v a2 s  . co  m*/
        public void generate(CodeEmitter code) {
            Map<String, Label> labelMap = Maps.newLinkedHashMap();
            Label defaultCase = new Label();
            Label done = new Label();
            for (PropertyAdapter.Property property : propertyAdapter.getProperties()) {
                labelMap.put(property.name, new Label());
            }
            propertyName.generate(code);
            code.emitStringSwitch(labelMap, defaultCase, true);
            MethodVisitor mv = code.getMethodVisitor();
            for (PropertyAdapter.Property property : propertyAdapter.getProperties()) {
                mv.visitLabel(labelMap.get(property.name));
                propertyAdapter.property(targetExpr, property.name).read().generate(code);
                code.box(property.type);
                mv.visitJumpInsn(Opcodes.GOTO, done);
            }
            mv.visitLabel(defaultCase);
            new NullExpr(AnyTypeWidget.getInstance()).generate(code);
            mv.visitLabel(done);
            mv.visitInsn(Opcodes.ARETURN);
        }
    });
}

From source file:com.torodb.torod.mongodb.commands.impl.general.update.MongoUpdatedToroDocumentBuilder.java

public void clear() {
    if (built) {//  w  w w  . jav a2 s. com
        built = false;
        updated = false;
        values = Maps.newLinkedHashMap();
    } else {
        values.clear();
    }
    subArrayBuilders.clear();
    subObjectBuilders.clear();
}

From source file:ch.puzzle.itc.mobiliar.business.generator.control.extracted.templates.GenerationOptions.java

private void populateProperties() {
    templateFiles = Maps.newLinkedHashMap();
    this.applications = Maps.newLinkedHashMap();
    this.contextProperties = Maps.newTreeMap();
    contextProperties.putAll(new BasePropertyCollector().propertiesForContext(context.getContext()));
}