static int toInt(O o) { if (o == null) ret 0; if (o cast Number) ret o.intValue(); if (o cast S) ret parseInt(o); if (o cast 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; }