Apache 2
Use it as you wish. Give me some credit if you fork it or copy major portions of it. Use the lib or copy it into your code, tweak it. Blog about. Use it. Give me feedback. I am doing this for the street cred and to learn.
Simple opinionated Java for the novice to expert level Java Programmer.
Low Ceremony. High Productivity.
Boon Home: http://richardhightower.github.io/site/Boon/Welcome.html
There is a maven repo at:
http://richardhightower.github.io/site/releases/mvn/repo/
Here are some basic Java types, list, array, veggies, primitive char array, and a primitive byte array.
//Boon works with lists, arrays, sets, maps, sorted maps, etc.
List<String> fruitList;
String [] fruitArray;
Set<String> veggiesSet;
char [] letters;
byte [] bytes;
NavigableMap <Integer, String> favoritesMap;
Map<String, Integer> map;
//In Java a TreeMap is a SortedMap and a NavigableMap by the way.
Boon comes with helper methods that allow you to easily create lists, sets, maps, concurrent maps, sorted maps, sorted sets, etc. The helper methods are safeList, list, set, sortedSet, safeSet, safeSortedSet, etc. The idea is to make Java feel more like list and maps are built in types.
veggiesSet = set( "salad", "broccoli", "spinach");
fruitList = list( "apple", "oranges", "pineapple");
fruitArray = array( "apple", "oranges", "pineapple");
letters = array( 'a', 'b', 'c');
bytes = array( new byte[]{0x1, 0x2, 0x3, 0x4});
There are even methods to create maps and sorted maps called map, sortedMap, safeMap (concurrent) and sortedSafeMap (concurrent). These were mainly created because Java does not have literals for lists, maps, etc.
favoritesMap = sortedMap(
2, "pineapple",
1, "oranges",
3, "apple"
);
map = map (
"pineapple", 2,
"oranges", 1,
"apple", 3
);
You can index maps, lists, arrays, etc. using the idx operator.
//Using idx to access a value.
assert idx( veggiesSet, "b").equals("broccoli");
assert idx( fruitList, 1 ).equals("oranges");
assert idx( fruitArray, 1 ).equals("oranges");
assert idx( letters, 1 ) == 'b';
assert idx( bytes, 1 ) == 0x2;
assert idx( favoritesMap, 2 ).equals("pineapple");
assert idx( map, "pineapple" ) == 2;
The idx operators works with negative indexes as well.
//Negative indexes
assert idx( fruitList, -2 ).equals("oranges");
assert idx( fruitArray, -2 ).equals("oranges");
assert idx( letters, -2 ) == 'b';
assert idx( bytes, -3 ) == 0x2;
Ruby, Groovy and Python have this feature. Now you can use this in Java as well. The Java version (Boon) works with primitive arrays (with no autoboxing).
Boon has the concept of universal operators similar to Python like len.
// Getting the length
assert len( veggiesSet ) == 3;
assert len( fruitList ) == 3;
assert len( fruitArray ) == 3;
assert len( letters ) == 3;
assert len( bytes ) == 4;
assert len( favoritesMap ) == 3;
assert len( map ) == 3;
Boon can read in an entire file in one line of code:
File testFile = new File(testDir, "testfile.txt");
List<String> lines = IO.readLines(testFile);
No really!
File testFile = new File(testDir, "testfile.txt");
List<String> lines = IO.readLines("~/github/boon/testfiles/testfile.txt");
There is also support for lambda expressions:
File testFile = new File(testDir, "testfile.txt");
IO.eachLine(testFile.toString(), (line, index) -> {
System.out.println(index + " " + line);
return true;
});
}
The readLines and read methods can read from URIs as well:
List<String> lines = IO.readLines("http://localhost:9666/test");
Thoughts? Write me at richard high tower AT g mail dot c-o-m (Rick Hightower).
If you are new to boon start here:
- Java Boon Byte Buffer Builder
- Java Boon Slice Notation
- Java Boon Slice's work with TreeSets
- Java Boon Description
- More...
- Boon Home
- Boon Source
- Introducing Boon October 2013
- Java Slice Notation
- What if Java collections were easy to search and sort?
- Boon HTTP utils
- Boon Java JSON parser Benchmarks or hell yeah JSON parsing is damn fast!
- Boon JSON parser is really damn fast! Part II
- Boon JSON parser Round III now just not fast as but much faster than other Java JSON parsers
- Boon World's fastest Java JSON parser Round IV from fast to blazing to rocket fuel aka Braggers going to brag
- Boon gets adopted by JSON Path as the default Java JSON parser
- Boon graphics showing just how fast Boon JSON parsing is - about 50% to 200% faster than the graphs shown here now so wicked fast became wickeder - just got sick of making graphics
- 10 minute guide to Boon JSON parsing after I added @JsonIgnore, @JsonProperty, @JsonView, @Exposes, etc.
- Hightower speaks to the master of Java JSON parsing, the king of speed The COW TOWN CODER!
- Boon provides easy Java objects from lists, from maps and from JSON.
Easily read in files into lines or a giant string with one method call. Works with files, URLs, class-path, etc. Boon IO support will surprise you how easy it is. Boon has Slice notation for dealing with Strings, Lists, primitive arrays, Tree Maps, etc. If you are from Groovy land, Ruby land, Python land, or whatever land, and you have to use Java then Boon might give you some relief from API bloat. If you are like me, and you like to use Java, then Boon is for you too. Boon lets Java be Java, but adds the missing productive APIs from Python, Ruby, and Groovy. Boon may not be Ruby or Groovy, but its a real Boon to Java development.
Core Boon will never have any dependencies. It will always be able to run as a single jar. This is not just NIH, but it is partly. My view of what Java needs is more inline with what Python, Ruby and Groovy provide. Boon is an addition on top of the JVM to make up the difference between the harder to use APIs that come with Java and the types of utilities that are built into Ruby, Python, PHP, Groovy etc. Boon is a Java centric view of those libs. The vision of Boon and the current implementation is really far apart.
===
Contact Info
blog|[twitter](https://twitter.com/RickHigh|[infoq]http://www.infoq.com/author/Rick-Hightower|[stackoverflow](http://stackoverflow.com/users/2876739/rickhigh)|[java lobby](http://java.dzone.com/users/rhightower)|Other | richard high tower AT g mail dot c-o-m (Rick Hightower)|work|cloud|nosql