Package com.flyingspaniel.nava.hash

Author:
Morgan Conrad

Prelimary utility code for pulling values from Maps. Useful because JavaScript/node.js usually use { } "objects" or "hashes" to pass settings and options.

To.java converts a raw Object "to" a different type, with two main method signatures:

  • type typeFrom(Object in) converts a single Object to a type
  • type typeOr(Object in, type...or) mimics the JavaScript || operator, returning the 2nd arg if the 1st is null
Hash.java gets the value from a Map. The major method signature is getType(Map map, String key, Type...or)
Note: Hash.Wrapper is likely to be changed.

Almost all methods take the varargs or... argument. Only the 0th value is ever used.

  • If the key is not in the map, and or is present, or[0] is returned
  • If the key is not in the map, and or is not present, a Hash.NoSuchKeyException is thrown