Difference between a deprecated and a legacy API?

From the official Sun glossary: deprecation: Refers to a class, interface, constructor, method or field that is no longer recommended, and may cease to exist in a future version. From the how-and-when to deprecate guide: You may have heard the term, “self-deprecating humor,” or humor that minimizes the speaker’s importance. A deprecated class or method … Read more

what’s a good persistent collections framework for use in java?

Just use the ones in Clojure directly. While obviously you might not want to use the language it’s self, you can still use the persistent collections directly as they are all just Java classes. import clojure.lang.PersistentHashMap; import clojure.lang.IPersistentMap; IPersistentMap map = PersistentHashMap.create(“key1”, “value1”); assert map.get(“key1”).equals(“value1”); IPersistentMap map2 = map.assoc(“key1”, “value1”); assert map2 != map; assert … Read more

Implementation of BlockingQueue: What are the differences between SynchronousQueue and LinkedBlockingQueue

SynchronousQueue is a very special kind of queue – it implements a rendezvous approach (producer waits until consumer is ready, consumer waits until producer is ready) behind the interface of Queue. Therefore you may need it only in the special cases when you need that particular semantics, for example, Single threading a task without queuing … Read more

In MongoDB, if collection is dropped, indexes dropped automatically as well?

Short answer: yes. Indexes are dropping on collection drop. You need to recreate an index. You may want to not to drop collection but remove all items in it with db.collection_name.remove({}). It will take more resources but leave your indexes. Actually it will need to delete all index data. That is why it is more … Read more

Properties file with a list as the value for an individual key

Try writing the properties as a comma separated list, then split the value after the properties file is loaded. For example a=one,two,three b=nine,ten,fourteen You can also use org.apache.commons.configuration and change the value delimiter using the AbstractConfiguration.setListDelimiter(char) method if you’re using comma in your values.

Most efficient way to find the collection of all ids in a collection of entities

Assuming you have class Entity { final long id; final String data; public long getId() { return id; } public String getData() { return data; } Entity(long id, String data) { this.id = id; this.data = data; } } In Java 8 you can write Collection<Entity> entities = Arrays.asList(new Entity(1, “one”), new Entity(11, “eleven”), new … Read more

How to remove duplicate objects in a List without equals/hashcode?

Here is the complete code which works for this scenario: class Blog { private String title; private String author; private String url; private String description; public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } public String getAuthor() { return author; } public void setAuthor(String author) { this.author = … Read more

Jackson JsonNode to typed Collection

Acquire an ObjectReader with ObjectMapper#readerFor(TypeReference) using a TypeReference describing the typed collection you want. Then use ObjectReader#readValue(JsonNode) to parse the JsonNode (presumably an ArrayNode). For example, to get a List<String> out of a JSON array containing only JSON strings ObjectMapper mapper = new ObjectMapper(); // example JsonNode JsonNode arrayNode = mapper.createArrayNode().add(“one”).add(“two”); // acquire reader for … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)