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.textocat.textokit.tokenizer.AnnotationToTokenFitter.java

@Override
public void process(JCas jCas) throws AnalysisEngineProcessException {
    Set<ST> anno2Remove = Sets.newLinkedHashSet();
    Map<ST, Offsets> anno2Fix = Maps.newLinkedHashMap();
    OverlapIndex<Token> tokenOverlapIndex = createOverlapIndex(JCasUtil.select(jCas, Token.class).iterator());
    ////  ww  w.  j  a v a 2  s  .  c o  m
    for (ST span : JCasUtil.select(jCas, targetTypeClass)) {
        Offsets spanOffsets = new Offsets(span);
        LinkedList<Token> overlappingTokens = Lists
                .newLinkedList(tokenOverlapIndex.getOverlapping(spanOffsets.getBegin(), spanOffsets.getEnd()));
        if (overlappingTokens.isEmpty()) {
            getLogger().warn(format("No overlapping tokens for typed span: %s", toPrettyString(span)));
            anno2Remove.add(span);
            continue;
        }
        // OT stands for 'overlapping token'
        Token firstOT = overlappingTokens.getFirst();
        Token lastOT = overlappingTokens.getLast();
        // check the first overlapping token
        if (firstOT.getBegin() != spanOffsets.getBegin()) {
            spanOffsets = new Offsets(firstOT.getBegin(), spanOffsets.getEnd());
        }
        // check the last overlapping token
        if (lastOT.getEnd() != spanOffsets.getEnd()) {
            spanOffsets = new Offsets(spanOffsets.getBegin(), lastOT.getEnd());
        }
        //
        if (!spanOffsets.isIdenticalWith(span)) {
            // fix
            anno2Fix.put(span, spanOffsets);
        }
    }
    // remove empty spans
    for (ST span : anno2Remove) {
        span.removeFromIndexes();
    }
    // fix span offsets
    for (Map.Entry<ST, Offsets> e : anno2Fix.entrySet()) {
        ST span = e.getKey();
        String oldText = span.getCoveredText();
        Offsets fixedOffsets = e.getValue();
        span.removeFromIndexes();
        span.setBegin(fixedOffsets.getBegin());
        span.setEnd(fixedOffsets.getEnd());
        span.addToIndexes();
        String newText = span.getCoveredText();
        getLogger().debug(format("Annotation offsets are fixed: '%s' => '%s'", oldText, newText));
    }
}

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

public Map<DefinitionSiteKind, double[]> getRawResults() {

    Map<DefinitionSiteKind, double[]> out = Maps.newLinkedHashMap();

    for (DefinitionSiteKind type : results.keySet()) {
        BoxplotData bpd = results.get(type);
        out.put(type, bpd.getRawValues());
    }/*from   www  .j  a v a 2  s  . c  o m*/

    return out;
}

From source file:com.isotrol.impe3.api.component.html.Tag.java

public Tag set(String attribute, String value) {
    if (attribute != null && value != null) {
        if (attributes == null) {
            attributes = Maps.newLinkedHashMap();
        }/*  w ww .  ja v a 2  s .c  o m*/
        attributes.put(attribute, HtmlUtils.htmlEscape(value));
    }
    return this;
}

From source file:com.google.auto.common.AnnotationMirrors.java

/**
 * Returns the {@link AnnotationMirror}'s map of {@link AnnotationValue} indexed by
 * {@link ExecutableElement}, supplying default values from the annotation if the
 * annotation property has not been set.  This is equivalent to
 * {@link Elements#getElementValuesWithDefaults(AnnotationMirror)} but can be called
 * statically without an {@link Elements} instance.
 *//*w  w  w  .  jav a 2s. c o  m*/
public static Map<ExecutableElement, AnnotationValue> getAnnotationValuesWithDefaults(
        AnnotationMirror annotation) {
    Map<ExecutableElement, AnnotationValue> values = Maps.newLinkedHashMap();
    Map<? extends ExecutableElement, ? extends AnnotationValue> declaredValues = annotation.getElementValues();
    for (ExecutableElement method : ElementFilter
            .methodsIn(annotation.getAnnotationType().asElement().getEnclosedElements())) {
        // Must iterate and put in this order, to ensure consistency in generated code.
        if (declaredValues.containsKey(method)) {
            values.put(method, declaredValues.get(method));
        } else if (method.getDefaultValue() != null) {
            values.put(method, method.getDefaultValue());
        } else {
            throw new IllegalStateException("Unset annotation value without default should never happen: "
                    + MoreElements.asType(method.getEnclosingElement()).getQualifiedName() + '.'
                    + method.getSimpleName() + "()");
        }
    }
    return values;
}

From source file:ivory.cascade.retrieval.CascadeThreadedQueryRunner.java

public CascadeThreadedQueryRunner(MRFBuilder builder, MRFExpander expander, int numThreads, int numHits,
        Map<Integer, Float[][]> savedResults, int K) {
    Preconditions.checkNotNull(builder);

    assert (numThreads > 0);
    assert (numHits > 0);

    mBuilder = builder;//  w w  w  .  ja v a 2  s .  c  o m
    mExpander = expander;
    mThreadPool = Executors.newFixedThreadPool(numThreads);
    mQueryResults = Maps.newLinkedHashMap();
    mNumHits = numHits;
    savedResults_prevStage = savedResults;
    mK = K;
}

From source file:org.gradle.api.internal.artifacts.ivyservice.resolveengine.result.FileDependencyCollectingGraphVisitor.java

@Override
public void start(DependencyGraphNode root) {
    Set<LocalFileDependencyMetadata> fileDependencies = ((LocalConfigurationMetadata) root.getMetadata())
            .getFiles();/*from  ww w  .jav a  2  s.co  m*/
    rootFiles = Maps.newLinkedHashMap();
    for (LocalFileDependencyMetadata fileDependency : fileDependencies) {
        LocalFileDependencyBackedArtifactSet artifacts = new LocalFileDependencyBackedArtifactSet(
                fileDependency);
        rootFiles.put(fileDependency.getSource(), artifacts);
        filesByConfiguration.put(root.getNodeId(), artifacts);
    }
}

From source file:org.apache.druid.query.select.SelectResultValueBuilder.java

public SelectResultValueBuilder(DateTime timestamp, PagingSpec pagingSpec, boolean descending) {
    this.timestamp = timestamp;
    this.pagingSpec = pagingSpec;
    this.descending = descending;
    this.dimensions = Sets.newHashSet();
    this.metrics = Sets.newHashSet();
    this.pagingIdentifiers = Maps.newLinkedHashMap();
    this.pQueue = instantiatePQueue();
}

From source file:org.jclouds.elasticstack.functions.MapToDriveInfo.java

@Override
public DriveInfo apply(Map<String, String> from) {
    if (from.size() == 0)
        return null;
    DriveInfo.Builder builder = new DriveInfo.Builder();
    builder.name(from.get("name"));
    if (from.containsKey("tags"))
        builder.tags(Splitter.on(' ').split(from.get("tags")));
    if (from.containsKey("status"))
        builder.status(DriveStatus.fromValue(from.get("status")));
    builder.metrics(buildMetrics(from));
    builder.user(from.get("user"));
    builder.encryptionCipher(from.get("encryption:cipher"));
    builder.uuid(from.get("drive"));
    if (from.containsKey("claim:type"))
        builder.claimType(ClaimType.fromValue(from.get("claim:type")));
    if (from.containsKey("claimed"))
        builder.claimed(Splitter.on(' ').split(from.get("claimed")));
    if (from.containsKey("readers"))
        builder.readers(Splitter.on(' ').split(from.get("readers")));
    if (from.containsKey("size"))
        builder.size(Long.valueOf(from.get("size")));
    Map<String, String> metadata = Maps.newLinkedHashMap();
    for (Entry<String, String> entry : from.entrySet()) {
        if (entry.getKey().startsWith("user:"))
            metadata.put(entry.getKey().substring(entry.getKey().indexOf(':') + 1), entry.getValue());
    }// w  w  w.  ja  va 2  s .  co m
    builder.userMetadata(metadata);
    try {
        return builder.build();
    } catch (NullPointerException e) {
        logger.trace("entry missing data: %s; %s", e.getMessage(), from);
        return null;
    }
}

From source file:org.smartdeveloperhub.harvesters.it.frontend.controller.LocalData.java

public LocalData() {
    this.collector = new Collector();
    this.contributors = Lists.newArrayList();
    this.commits = Lists.newArrayList();
    this.projects = Lists.newArrayList();
    this.projectComponents = Maps.newLinkedHashMap();
    this.projectVersions = Maps.newLinkedHashMap();
    this.projectIssues = Maps.newLinkedHashMap();
}

From source file:org.eclipse.xtext.xbase.validation.XbaseConfigurableIssueCodes.java

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

        @Override//ww  w  . j  a va  2  s. com
        public void accept(PreferenceKey prefKey) {
            map.put(prefKey.getId(), prefKey);
        }
    });
    this.issueCodes = ImmutableMap.copyOf(map);
}