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.samovich.service.blueprint.webservice.Blueprint.java

@GET
@Path("blueprint")
@Produces({ "application/json" })
public Response getAppHello() {
    Map<String, Object> objectResponse = Maps.newLinkedHashMap();
    objectResponse.put("Description", "Spring Boot CXF Client Application with JAX-RS");
    return Response.ok(objectResponse).build();
}

From source file:org.apache.isis.core.commons.configbuilder.PrimerForSystemProperties.java

private static Map<String, String> fromProperties(final Properties properties) {
    final LinkedHashMap<String, String> map = Maps.newLinkedHashMap();
    for (final Map.Entry<Object, Object> entry : properties.entrySet()) {
        final Object key = entry.getKey();
        final Object value = entry.getValue();
        if (key instanceof String && value instanceof String) {
            map.put((String) key, (String) value);
        }/*from   w ww . j a v  a2 s. c o  m*/
    }
    return map;
}

From source file:com.cinchapi.common.collect.AnyMaps.java

/**
 * Return a {@link Map} that contains the specified
 * {@code key}/{@code value} pair.//from  ww w .  j a  va  2  s. co m
 * 
 * @param key
 * @param value
 * @return the {@link Map}
 */
public static <K, V> Map<K, V> create(K key, V value) {
    LinkedHashMap<K, V> map = Maps.newLinkedHashMap();
    map.put(key, value);
    return map;
}

From source file:com.cloudera.science.ml.core.records.Header.java

public static Header fromFile(File headerFile) throws IOException {
    LinkedHashMap<String, Type> data = Maps.newLinkedHashMap();
    boolean hasId = false;
    for (String line : Files.readLines(headerFile, Charsets.UTF_8)) {
        if (line.contains(",")) {
            String[] pieces = COMMA.split(line);
            if (pieces.length != 2) {
                throw new IllegalArgumentException("Invalid header file row: " + line);
            }//from   ww  w. j a  v  a2s  .co m
            String name = pieces[0];
            String meta = pieces[1].toLowerCase(Locale.ENGLISH).trim();
            if (meta.startsWith("ignore")) {
                data.put(name, Type.IGNORED);
            } else if (meta.startsWith("id")) {
                if (hasId) {
                    throw new IllegalArgumentException("Multiple ID columns in header file");
                } else {
                    data.put(name, Type.ID);
                    hasId = true;
                }
            } else if (SYMBOL_META.contains(meta)) {
                data.put(name, Type.SYMBOLIC);
            } else if (NUMERIC_META.contains(meta)) {
                data.put(name, Type.NUMERIC);
            } else {
                throw new IllegalArgumentException(
                        String.format("Did not recognize metadata %s for field %s", meta, name));
            }
        } else if (!line.matches("\\s*")) {
            data.put(line, Type.NUMERIC);
        }
    }
    return new Header(data);
}

From source file:org.opendaylight.controller.cluster.datastore.utils.InMemoryJournal.java

public static void addEntry(String persistenceId, long sequenceNr, Object data) {
    Map<Long, Object> journal = journals.get(persistenceId);
    if (journal == null) {
        journal = Maps.newLinkedHashMap();
        journals.put(persistenceId, journal);
    }//from  w w w .j a v  a2 s . c  o m

    synchronized (journal) {
        journal.put(sequenceNr, data);
    }
}

From source file:org.jclouds.vcloud.util.Utils.java

public static Map<String, String> cleanseAttributes(Attributes in) {
    Map<String, String> attrs = Maps.newLinkedHashMap();
    for (int i = 0; i < in.getLength(); i++) {
        String name = in.getQName(i);
        if (name.indexOf(':') != -1)
            name = name.substring(name.indexOf(':') + 1);
        attrs.put(name, in.getValue(i));
    }/*www. jav a  2 s  .  c  o m*/
    return attrs;
}

From source file:org.openehr.adl.parser.tree.OdinObject.java

static OdinObject parse(adlParser.OdinObjectValueContext context) {
    if (context == null)
        return new OdinObject(null, ImmutableMap.<String, adlParser.OdinValueContext>of());

    Map<String, adlParser.OdinValueContext> properties = Maps.newLinkedHashMap();
    List<adlParser.OdinObjectPropertyContext> adlObjectProperties = context.odinObjectProperty();
    for (adlParser.OdinObjectPropertyContext adlObjectProperty : adlObjectProperties) {
        String name = adlObjectProperty.identifier().getText();
        properties.put(name, adlObjectProperty.odinValue());

    }//  w  w  w. ja  va2  s  . co  m
    return new OdinObject(context.start, properties);
}

From source file:com.ibm.og.json.OperationConfig.java

public OperationConfig() {
    this.weight = 0.0;
    this.host = null;
    this.object = new ObjectConfig();
    this.headers = Maps.newLinkedHashMap();
    this.parameters = Maps.newLinkedHashMap();
    this.body = BodySource.NONE;
    this.container = new ContainerConfig();
}

From source file:com.yahoo.yqlplus.engine.internal.java.types.RecordMapWrapper.java

public RecordMapWrapper() {
    this.fields = Maps.newLinkedHashMap();
}

From source file:org.openehr.designer.support.units.UnitsProvider.java

public static UnitsProvider fromXml(InputStream inputStream) throws IOException, SAXException {
    Document document = WtUtils.defaultDocumentBuilder().parse(inputStream);

    List<Element> elements = WtUtils.children(document.getDocumentElement());

    Map<String, Property> propertyMap = Maps.newLinkedHashMap();

    elements.stream().filter(element -> element.getLocalName().equals("Property")).forEach(element -> {
        Property property = new Property();
        property.setLabel(element.getAttribute("Text"));
        property.setOpenEhrId(element.getAttribute("openEHR"));
        property.setUnits(new ArrayList<>());
        propertyMap.put(element.getAttribute("id"), property);
    });//from   ww  w . ja  v  a  2 s  .  co m

    elements.stream().filter(element -> element.getLocalName().equals("Unit")).forEach(element -> {
        Unit unit = new Unit();
        unit.setCode(element.getAttribute("Text"));
        unit.setLabel(element.getAttribute("name"));
        if (StringUtils.isEmpty(unit.getLabel())) {
            unit.setLabel(unit.getCode());
        }
        unit.setPrimary(Boolean.parseBoolean(element.getAttribute("primary")));
        Property property = propertyMap.get(element.getAttribute("property_id"));

        property.getUnits().add(unit);
    });

    return new UnitsProvider(Lists.newArrayList(propertyMap.values()));
}