More than one year after the 0.8.1 release, LinkedIn just released version 0.9 of it's scalable nosql database Project Voldemort.
Go here for the release notes.
Saturday, July 23, 2011
Sunday, July 17, 2011
Generic Java Methods And Type Inference
To create test data in Java I often wrote things like this:
By the way: I love the JUnit 4 org.junit.matchers.JUnitMatchers.* and org.hamcrest.CoreMatchers.* Matchers :-)
Of course you do not have to implement this code yourself. You can for example use the great guava libraries.
List<String> names = new ArrayList<String>(); names.add("Tick"); names.add("Trick"); names.add("Track"); ...Generic methods and type inference make this task a lot easier:
public static <T> List<T> newArrayList(T... entries) { return new ArrayList<T>(Arrays.asList(entries)); }The following JUnit test shows how to use this code:
public class ListBuilderTest { @Test public void test() { List<String> l = ListBuilder.newArrayList("Tick", "Trick", "Track"); assertThat(l.size(), equalTo(3)); assertThat(l, hasItem("Tick")); assertThat(l, hasItem("Trick")); assertThat(l, hasItem("Track")); } }
By the way: I love the JUnit 4 org.junit.matchers.JUnitMatchers.* and org.hamcrest.CoreMatchers.* Matchers :-)
Of course you do not have to implement this code yourself. You can for example use the great guava libraries.
Subscribe to:
Posts (Atom)