static int toInt(O o) { if (o == null) ret 0; if (o instanceof Number) ret ((Number) o).intValue(); if (o instanceof S) ret parseInt((S) o); if (o instanceof Bool) ret boolToInt(o); throw fail("woot not int: " + getClassName(o)); } static int toInt(long l) { if (l != (int) l) fail("Too large for int: " + l); ret (int) l; }