List of usage examples for java.util LinkedHashMap LinkedHashMap
public LinkedHashMap(Map<? extends K, ? extends V> m)
From source file:mx.bigdata.anyobject.MapBasedAnyObject.java
public MapBasedAnyObject(Map map, String separator) { this.map = new LinkedHashMap(map); this.separator = separator; }
From source file:com.rodiontsev.maven.plugins.buildinfo.providers.ProjectInfoProvider.java
public Map<String, String> getInfo(MavenProject project, BuildInfoMojo mojo) { // finite set of project properties we expose final Map<String, String> props = new LinkedHashMap<String, String>(65); props.put("project.id", project.getId()); props.put("project.groupId", project.getGroupId()); props.put("project.artifactId", project.getArtifactId()); props.put("project.version", project.getVersion()); props.put("project.name", project.getName()); props.put("project.description", project.getDescription()); props.put("project.modelVersion", project.getModelVersion()); props.put("project.inceptionYear", project.getInceptionYear()); props.put("project.packaging", project.getPackaging()); props.put("project.url", project.getUrl()); final MavenProject parent = project.getParent(); if (parent != null) { props.put("project.parent.id", parent.getId()); props.put("project.parent.groupId", parent.getGroupId()); props.put("project.parent.artifactId", parent.getArtifactId()); props.put("project.parent.version", parent.getVersion()); props.put("project.parent.name", parent.getName()); props.put("project.parent.description", parent.getDescription()); props.put("project.parent.modelVersion", parent.getModelVersion()); props.put("project.parent.inceptionYear", parent.getInceptionYear()); props.put("project.parent.packaging", parent.getPackaging()); props.put("project.parent.url", parent.getUrl()); }//from w ww. j a va 2 s. com // properties the user wants Map<String, String> info = new LinkedHashMap<String, String>(); for (String propertyName : mojo.getProjectProperties()) { String prop = props.get(propertyName); if (prop != null) { info.put(propertyName, prop); } } info.put("build.time", DateFormatUtils.format(new Date(), "d MMMM yyyy, HH:mm:ss ZZ", Locale.ENGLISH)); return info; }
From source file:com.karus.danktitles.commands.HelpSubcommand.java
public HelpSubcommand() { commands = new LinkedHashMap<>(DankTitles.instance.getDescription().getCommands().entrySet().stream() .collect(Collectors.toMap((e) -> e.getKey(), (e) -> new MutablePair<>((String) e.getValue().get("permission"), (String) e.getValue().get("usage"))))); }
From source file:PropertiesMap.java
public PropertiesMap(int initialCapacity) { props = new LinkedHashMap<String, Object>(initialCapacity); }
From source file:edu.wisc.web.util.StatusMappingExceptionResolver.java
public void setViewStatusCodeMappings(Map<String, Integer> viewStatusCodeMappings) { this.viewStatusCodeMappings = new LinkedHashMap<String, Integer>(viewStatusCodeMappings); }
From source file:Main.java
/** * Join the two given maps to one by checking if one of the two maps already fulfills everything. Be aware that the * newly created collection is unmodifiable but will change if the underlying collections change! * * @param <K> The key type/*from ww w .jav a2s. c om*/ * @param <V> The value type * @param first The first {@link Map} to join * @param second The second {@link Map} to join * * @return A {@link Map} with the joined content (can be one of the given map if the other is empty or null) */ public static <K, V> Map<K, V> joinMapUnmodifiable(Map<K, V> first, Map<K, V> second) { if (first == null || first.isEmpty()) { if (second == null || second.isEmpty()) { return Collections.emptyMap(); } else { return Collections.unmodifiableMap(second); } } else if (second == null || second.isEmpty()) { return Collections.unmodifiableMap(first); } else { Map<K, V> temp = new LinkedHashMap<K, V>(first.size() + second.size()); temp.putAll(first); temp.putAll(second); return Collections.unmodifiableMap(temp); } }
From source file:IdentityMap.java
/** * Return a new instance of this class, with iteration * order defined as the order in which entries were added * * @param size The size of the map to create * @return/*from w w w . ja v a 2 s. co m*/ */ public static Map instantiateSequenced(int size) { return new IdentityMap(new LinkedHashMap(size)); }
From source file:com.cprassoc.solr.auth.SolrAuthActionController.java
public static String addUser(String uname, String pw) { String result = ""; String path = SOLR.getSolrBaseUrl() + AUTHENTICATION_URL_PART; String data = "{ \"set-user\": {\"" + uname + "\" : \"" + pw + "\" }}"; /*//w w w . j av a 2s . c o m curl --user solr:SolrRocks http://localhost:8983/solr/admin/authentication -H 'Content-type:application/json'-d '{ "set-user": {"tom" : "TomIsCool" , "harry":"HarrysSecret"}}' */ // first, post the user to solr. result = SOLR.post(path, data); Log.log(SolrAuthActionController.class, result); // then pull back authentication to get the pwd hash String authentication = SolrAuthActionController.SOLR.getAuthentication(); JSONObject authoeJson = new JSONObject(authentication); LinkedHashMap authoeMap = new LinkedHashMap(JsonHelper.jsonToMap(authoeJson)); Authentication newauthentication = new Authentication(authoeMap); // return the new pwd hash as result. String pwhash = newauthentication.getCredentials().get(uname); Log.log(SolrAuthActionController.class, "New User hash: " + pwhash); return pwhash; }
From source file:com.nortal.petit.beanmapper.ExtendedBeanMapping.java
@Override public Map<String, Property<B, Object>> props() { Map<String, Property<B, Object>> props = new LinkedHashMap<String, Property<B, Object>>( beanMapping.props());/* w ww . j a v a 2s . c om*/ for (String key : extendedProps.keySet()) { Property<B, Object> property = extendedProps.get(key); props.put(key, property); } return props; }
From source file:Main.java
/** * Takes arrays of {@code keys} and {@code values} and merges them * together to form a {@link Map}. The returned {@code Map} is a * {@link LinkedHashMap} and is truncated in length to the length of the * shorter parameter.//from w w w.j a va 2 s. co m * * <p>This is intended for use as {@literal "varargs"} supplied to * {@link #arr(Object...)}. Rather than doing something ugly like: * <pre> * Map<String, String> mappy = new LinkedHashMap<String, String>(); * mappy.put("key0", "val0"); * mappy.put("key1", "val1"); * ... * mappy.put("keyN", "valN"); * </pre> * * Simply do like so: * <pre> * mappy = zipMap( * arr("key0", "key1", ..., "keyN"), * arr("val0", "val1", ..., "valN")); * </pre> * * <p>The latter approach also allows you to make {@code static final} * {@link Map}s much more easily. * * @param keys Array whose elements will be the keys in a {@code Map}. * @param values Array whose elements will the values in a {@code Map}. * * @return A {@code Map} whose entries are of the form * {@code keys[N], values[N]}. * * @see #arr(Object...) * @see #zipMap(java.util.Collection, java.util.Collection) */ public static <K, V> Map<K, V> zipMap(K[] keys, V[] values) { Map<K, V> zipped = new LinkedHashMap<>(keys.length); for (int i = 0; (i < keys.length && i < values.length); i++) { zipped.put(keys[i], values[i]); } return zipped; }