did some refactoring.
updated the javadocs
added predicate contracts
added default case that throws an assertion exception.