version: 0.4.0
Overview
A collection of small java utilities and data structures.
- licence: MPL 1.1
- platform: java 6
- lastest version 0.4.0 from 2010.09.02
- Note: interface is not stable yet
Download
- current version 0.4.0 alpha
- source code google code
Changes
0.4
- moved artifact package in own lib (artig-lib)
- ducktyping
- CatchAll
- Strings utils (i.e. join)
0.2
Iterators
- Iterators for Strings: LineIterator, WordIterator, CharacterIterartor.
- Parallel Iterator: Iterate over 2 Iterables together.
Tupples
- pairs, used by iterators.
Lexicographical
Methods for Lexicographical compare
Fixes
Added equals, hashcode and toString to some classes.
Features
Count
Add index, isFirst(), isLast() to any iterable.
List<String> stringlist = Arrays.asList( "A", "B", "C" );
for(Count<String> str : Count.count( stringlist)) }
System.out.println("idx: " + str.idx() + " = " + str.obj() + (str.isLast() ? " last" : "" ) + (str.isFirst() ? " first" : "" )) ;
}
prints
idx: 1 = A first
idx: 2 = B
idx: 3 = C last
Unchecked
To enable a more compact and arguably more consistent coding style I tunnel checked exception with an unchecked throwable: Unchecked.
Code signatures can generally be formulated without throws. The caller of such methods can still expect to handle Exceptions.
public void foo() {
try {
new URL( "foo" );
} catch (MalformedURLException e) {
throw Unchecked.wrap(e);
}
}
foo is a method not declaring any throws. But it still does.
Functions
Simple interfaces to declare standard functions / lambdas. Small interfaces with a single method usually don't provide much information. Using the same F0 interface
instead makes for more compact code.
Data Structures
BiMap
A bidirection map.
BFStack
A stack with forward and backward navigation inspired by browser histories.
MRU
Most Recently Used Collection.
Once
A reference to be updated exactly once. This is a nice class for fluent code.
ESet
A set with a get method. If the elements of the set have an equals based on only some members you can create slim objects and test whether the full version is already in the set. And if so retrieve the full version.
Strings
A utility class for strings and lists of strings.
It concatenates the elements of a list. It can filter, transform, prefix and postfix the list.
e.g.
List<Integer> ints = Arrays.asList( 1, 2, 3);
Strings.join( int ).toString();
=> "1, 2, 3"
Strings.join( int ).toString().prefix(">").postfix("<");
=> ">1, 2, 3<"
Strings.join( ints ).trans( new F1<String, Integer>() {
@Override
public String call(Integer integer) {
return new Integer(integer * 2).toString();
}
}).toString());
=> "2, 4, 6"





