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.buildship.core.workspace.internal.SourceFolderUpdater.java

private SourceFolderUpdater(IJavaProject project, List<OmniEclipseSourceDirectory> sourceFolders) {
    this.project = Preconditions.checkNotNull(project);
    this.sourceFoldersByPath = Maps.newLinkedHashMap();
    for (OmniEclipseSourceDirectory sourceFolder : sourceFolders) {
        IPath fullPath = project.getProject().getFullPath().append(sourceFolder.getPath());
        this.sourceFoldersByPath.put(fullPath, sourceFolder);
    }/*from   www.j  a v a  2  s .c  om*/
}

From source file:org.splevo.jamopp.diffing.similarity.SimilarityChecker.java

/**
 * Default constructor for a similarity checker without any normalization configurations.
 */// w  w  w  .  j a  v a 2 s .  c o  m
public SimilarityChecker() {
    this.classifierNormalizations = Maps.newLinkedHashMap();
    this.compilationUnitNormalizations = Maps.newLinkedHashMap();
    this.packageNormalizations = Maps.newLinkedHashMap();
}

From source file:cc.recommenders.evaluation.distribution.calc.FeatureComparisonProvider.java

@Override
protected Map<String, String> getOptions() {
    Map<String, String> options = Maps.newLinkedHashMap();
    boolean[] trueAndFalse = new boolean[] { false, true };
    for (boolean useClass : trueAndFalse) {
        for (boolean useDef : trueAndFalse) {
            for (boolean useParam : trueAndFalse) {
                String config = String.format("+%s%s%s", _(useClass, "C"), _(useDef, "D"), _(useParam, "P"));
                options.put("BMN" + config,
                        bmn().c(useClass).d(useDef).p(useParam).useFloat().ignore(false).min(30).get());
                options.put("PBN0" + config,
                        pbn(0).c(useClass).d(useDef).p(useParam).useFloat().ignore(false).min(30).get());
                options.put("PBN15" + config,
                        pbn(15).c(useClass).d(useDef).p(useParam).useFloat().ignore(false).min(30).get());
                options.put("PBN25" + config,
                        pbn(25).c(useClass).d(useDef).p(useParam).useFloat().ignore(false).min(30).get());
                options.put("PBN30" + config,
                        pbn(30).c(useClass).d(useDef).p(useParam).useFloat().ignore(false).min(30).get());
                options.put("PBN40" + config,
                        pbn(40).c(useClass).d(useDef).p(useParam).useFloat().ignore(false).min(30).get());
                options.put("PBN60" + config,
                        pbn(60).c(useClass).d(useDef).p(useParam).useFloat().ignore(false).min(30).get());
            }/*from   w  ww  .  j av a2  s . com*/
        }
    }
    return options;
}

From source file:no.ssb.vtl.model.StaticDataset.java

@Override
public Optional<Map<String, Integer>> getDistinctValuesCount() {
    List<Set<Object>> seenHashes = Lists.newArrayList();
    DataStructure structure = getDataStructure();

    for (int i = 0; i < structure.size(); i++)
        seenHashes.add(Sets.newHashSet());

    getData().map(structure::asMap).forEach(map -> {
        Iterator<VTLObject> valuesIterator = map.values().iterator();
        Iterator<Set<Object>> hashIterator = seenHashes.iterator();
        while (valuesIterator.hasNext() && hashIterator.hasNext()) {
            VTLObject value = valuesIterator.next();
            Set<Object> seen = hashIterator.next();
            if (!seen.contains(value))
                seen.add(value);//from  w w w .  j a va2 s  . c om
        }
    });

    LinkedHashMap<String, Integer> count = Maps.newLinkedHashMap();
    Iterator<Set<Object>> iterator = seenHashes.iterator();
    for (String name : structure.keySet())
        count.put(name, iterator.next().size());

    return Optional.of(count);

}

From source file:org.ldp4j.application.data.MutableDataSet.java

MutableDataSet(Name<?> name) {
    this.name = name;
    this.individuals = Maps.newLinkedHashMap();
    this.factory = new IndividualFactory(this);
}

From source file:com.android.tools.idea.gradle.dsl.parser.elements.GradleDslExpressionMap.java

/**
 * Returns the map from properties of the type {@link String} and values of the type {@code clazz}.
 *
 * <p>Returns an empty map when the given there are no values of type {@code clazz}.
 *///  w ww .ja v  a  2s.  c o  m
@NotNull
public <V> Map<String, GradleNotNullValue<V>> getValues(@NotNull Class<V> clazz) {
    Map<String, GradleNotNullValue<V>> result = Maps.newLinkedHashMap();
    for (Map.Entry<String, GradleDslElement> entry : getPropertyElements().entrySet()) {
        GradleDslElement propertyElement = entry.getValue();
        if (propertyElement instanceof GradleDslExpression) {
            V value = ((GradleDslExpression) propertyElement).getValue(clazz);
            if (value != null) {
                result.put(entry.getKey(), new GradleNotNullValue<>(propertyElement, value));
            }
        }
    }
    return result;
}

From source file:com.cinchapi.concourse.util.Transformers.java

/**
 * Transform the keys in {@code original} with the {@code keys} function
 * and each of the values with the {@code values} function and return the
 * result.//from w  w  w. j av  a2 s.  c  o  m
 * <p>
 * <strong>WARNING:</strong> There is the potential for data loss in the
 * event that {@code function} returns duplicate transformed results for
 * items in {@code original}.
 * </p>
 * 
 * @param original
 * @param keys
 * @param values
 * @return the transformed Map
 */
public static <K, K2, V, V2> Map<K2, Set<V2>> transformMapSet(Map<K, Set<V>> original,
        Function<? super K, ? extends K2> keys, Function<? super V, ? extends V2> values) {
    Map<K2, Set<V2>> transformed = Maps.newLinkedHashMap();
    for (Map.Entry<K, Set<V>> entry : original.entrySet()) {
        transformed.put(keys.apply(entry.getKey()), transformSet(entry.getValue(), values));
    }
    return transformed;
}

From source file:org.pshdl.model.types.builtIn.busses.memorymodel.MemoryModel.java

public static HDLInterface buildHDLInterface(Unit unit, List<Row> rows) {
    final Map<String, Definition> definitions = Maps.newLinkedHashMap();
    final Map<String, Integer> defDimension = Maps.newLinkedHashMap();
    for (final Row row : rows) {
        for (final NamedElement ne : row.definitions) {
            final Definition def = (Definition) ne;
            final String name = def.name;
            final Definition stockDef = definitions.get(name);
            if ((stockDef != null) && !def.equals(stockDef) && (def.type != Type.UNUSED))
                throw new IllegalArgumentException(
                        "Two definitions with same name exist, but their type differs:" + def + " vs "
                                + stockDef);
            definitions.put(name, def);/*w ww . j ava2  s . c o m*/
            final Integer val = defDimension.get(name);
            if (val == null) {
                defDimension.put(name, 1);
            } else {
                defDimension.put(name, val + 1);
            }

        }
    }
    HDLInterface hdi = new HDLInterface();
    for (final Definition def : definitions.values()) {
        HDLPrimitive type = null;
        switch (def.type) {
        case BIT:
            if (def.width == -1) {
                type = HDLPrimitive.getBit();
            } else {
                type = HDLPrimitive.getBitvector().setWidth(HDLLiteral.get(def.width));
            }
            break;
        case INT:
            if (def.width == -1) {
                type = HDLPrimitive.getInteger();
            } else {
                type = HDLPrimitive.getInt().setWidth(HDLLiteral.get(def.width));
            }
            break;
        case UINT:
            if (def.width == -1) {
                type = HDLPrimitive.getNatural();
            } else {
                type = HDLPrimitive.getUint().setWidth(HDLLiteral.get(def.width));
            }
            break;
        case UNUSED:
            continue;
        }
        if (type == null)
            throw new IllegalArgumentException("Should not happen");
        HDLVariableDeclaration hdv = new HDLVariableDeclaration().setType(type);
        hdv = hdv.setRegister(def.register ? HDLRegisterConfig.defaultConfig() : null);
        switch (def.rw) {
        case r:
            hdv = hdv.setDirection(HDLDirection.IN);
            break;
        case rw:
            hdv = hdv.setDirection(HDLDirection.INOUT);
            break;
        case w:
            hdv = hdv.setDirection(HDLDirection.OUT);
            break;
        }
        HDLVariable var = new HDLVariable().setName(def.name);
        final Integer dim = defDimension.get(def.name);
        if (dim != 1) {
            var = var.addDimensions(HDLLiteral.get(dim));
        }
        hdv = hdv.addVariables(var);
        hdi = hdi.addPorts(hdv);
    }
    return hdi;
}

From source file:org.ldp4j.application.kernel.persistence.jpa.JPAContainer.java

JPAContainer(ResourceId id, ResourceId parentId) {
    super(id, parentId);
    this.members = Maps.newLinkedHashMap();
    this.slugs = Maps.newLinkedHashMap();
    this.memberCounter = 0;
}

From source file:brooklyn.rest.resources.PolicyResource.java

@Override
public Map<String, Boolean> batchConfigRead(String application, String entityToken) {
    // TODO: add test
    EntityLocal entity = brooklyn().getEntity(application, entityToken);
    Map<String, Boolean> result = Maps.newLinkedHashMap();
    for (Policy p : entity.getPolicies()) {
        result.put(p.getId(), !p.isSuspended());
    }/*from  www  .  j  ava2s.  c  om*/
    return result;
}