List of usage examples for java.util LinkedHashMap LinkedHashMap
public LinkedHashMap(Map<? extends K, ? extends V> m)
From source file:Main.java
public static <KEY, VALUE> LinkedHashMap<KEY, VALUE> newLinkedHashMapSized(int size) { return new LinkedHashMap<KEY, VALUE>(size); }
From source file:Main.java
/** * Creates a new sorted map, based on the values from the given map and Comparator. * /*from w ww. j a v a 2 s .co m*/ * @param map the map which needs to be sorted * @param valueComparator the Comparator * @return a new sorted map */ public static <K, V> Map<K, V> sortMapByValue(Map<K, V> map, Comparator<Entry<K, V>> valueComparator) { if (map == null) { return Collections.emptyMap(); } List<Entry<K, V>> entriesList = new LinkedList<>(map.entrySet()); // Sort based on the map's values Collections.sort(entriesList, valueComparator); Map<K, V> orderedMap = new LinkedHashMap<>(entriesList.size()); for (Entry<K, V> entry : entriesList) { orderedMap.put(entry.getKey(), entry.getValue()); } return orderedMap; }
From source file:com.almende.eve.protocol.jsonrpc.formats.Params.java
/** * Instantiates a new params./* w w w. j a v a2 s . c o m*/ * * @param node * the node */ public Params(final ObjectNode node) { super(JOM.getInstance().getNodeFactory(), new LinkedHashMap<String, JsonNode>(node != null ? node.size() : 2)); if (node != null) { this.setAll(node); } }
From source file:Main.java
private static Object getElementValue(Node node) { NodeList nodes = node.getChildNodes(); int childCount = nodes.getLength(); int childElementCount = 0; for (int i = 0; i < childCount; i++) { Node child = nodes.item(i); if (child.getNodeType() == Node.ELEMENT_NODE) { childElementCount++;/*from www . j av a2 s .c om*/ } } if (childElementCount == 0) { return node.getTextContent(); } Map<String, Object> map = new LinkedHashMap<>(childElementCount); for (int i = 0; i < childCount; i++) { Node child = nodes.item(i); if (child.getNodeType() != Node.ELEMENT_NODE) { continue; } String childName = child.getNodeName(); Object childValue = child.hasChildNodes() ? toObject(child) : null; // auto detect repeating elements if (map.containsKey(childName)) { Object temp = map.get(childName); if (temp instanceof List) { List list = (List) temp; list.add(childValue); } else { List list = new ArrayList(childCount); map.put(childName, list); list.add(temp); list.add(childValue); } } else { map.put(childName, childValue); } } return map; }
From source file:ch.rasc.extclassgenerator.validation.GenericValidation.java
public GenericValidation(String type, String field, Map<String, Object> options) { super(type, field); if (options != null) { this.options = new LinkedHashMap<String, Object>(options); } else {/*from w ww.java 2 s . c o m*/ this.options = null; } }
From source file:com.almende.eve.capabilities.Config.java
/** * Instantiates a new config. */ public Config() { super(JOM.getInstance().getNodeFactory(), new LinkedHashMap<String, JsonNode>(2)); }
From source file:com.enonic.cms.core.security.userstore.connector.config.UserStoreConnectorConfigLoader.java
public Map<String, UserStoreConnectorConfig> getAllUserStoreConnectorConfigs() { Collection<String> allNames = doGetAllUserStoreConnectorNames(); Map<String, UserStoreConnectorConfig> configs = new LinkedHashMap<String, UserStoreConnectorConfig>( allNames.size());/*from ww w. jav a 2 s . co m*/ for (final String name : allNames) { configs.put(name, doGetUserStoreConnectorConfig(name, true)); } return configs; }
From source file:com.revolsys.util.JavaBeanUtil.java
/** * Clone the value if it has a clone method. * * @param value The value to clone./*w w w . ja v a2 s .co m*/ * @return The cloned value. */ @SuppressWarnings("unchecked") public static <V> V clone(final V value) { if (value instanceof Map) { final Map<Object, Object> sourceMap = (Map<Object, Object>) value; final Map<Object, Object> map = new LinkedHashMap<>(sourceMap); for (final Entry<Object, Object> entry : sourceMap.entrySet()) { final Object key = entry.getKey(); final Object mapValue = entry.getValue(); final Object clonedMapValue = clone(mapValue); map.put(key, clonedMapValue); } return (V) map; } else if (value instanceof List) { final List<?> list = (List<?>) value; final List<Object> cloneList = new ArrayList<>(); for (final Object object : list) { final Object clonedObject = clone(object); cloneList.add(clonedObject); } return (V) cloneList; } else if (value instanceof Cloneable) { try { final Class<? extends Object> valueClass = value.getClass(); final Method method = valueClass.getMethod("clone", ARRAY_CLASS_0); if (method != null) { return (V) method.invoke(value, ARRAY_OBJECT_0); } } catch (final Throwable e) { return Exceptions.throwUncheckedException(e); } } return value; }
From source file:com.almende.eve.capabilities.Config.java
private Config(final ObjectNode node) { super(JOM.getInstance().getNodeFactory(), new LinkedHashMap<String, JsonNode>(node != null ? node.size() : 2)); if (node != null) { this.setAll(node); }/*from w w w .j a v a 2 s .c om*/ }
From source file:ca.uhn.fhir.rest.server.FifoMemoryPagingProvider.java
public FifoMemoryPagingProvider(int theSize) { Validate.isTrue(theSize > 0, "theSize must be greater than 0"); mySize = theSize;//from w ww. j av a 2 s . c o m myBundleProviders = new LinkedHashMap<String, IBundleProvider>(mySize); }