class ObjectFunction {

   @FunctionMeta(description = "Length of String, or array", example = "${w:length(obj)}")
   public static Object length(Object obj) {
      if (obj == null) {
         return null;
      } else if (obj instanceof CharSequence) {
         return ((CharSequence) obj).length();
      } else if (obj.getClass().isArray()) {
         return Array.getLength(obj);
      } else {
         try {
            return Reflects.forMethod().invokeMethod(obj, "getLength", (Object[]) null);
         } catch (Exception e) {
            return null;
         }
      }
   }

}