private static Object fromObject(Object o, Class<?> type) {
      if (o == null) return null;
      if (type.isAssignableFrom(o.getClass())) return o;
      if ("null".equals(o)) return null;

      String value = String.valueOf(o).trim();
      if (type == int.class) return Integer.parseInt(value);
      if (type == boolean.class) return "yes".equalsIgnoreCase(value) || "true".equalsIgnoreCase(value);
      if (type == byte.class) return Byte.parseByte(value);
      if (type == short.class) return Short.parseShort(value);
      if (type == double.class) return Double.parseDouble(value);
      if (type == float.class) return Float.parseFloat(value);

      String[] s = value.split("(?i)\\s*(?:[x@:]|[a-z]+:)\\s*", 6);
      if (type == Dimension.class) {
        if (s.length == 2) return new Dimension(Integer.parseInt(s[0]), Integer.parseInt(s[1]));
      }
      else if (type == Point.class) {
        if (s.length == 2) return new Point(Integer.parseInt(s[0]), Integer.parseInt(s[1]));
      }
      else if (type == Rectangle.class) {
        if (s.length >= 5) {
          return new Rectangle(Integer.parseInt(s[3]), Integer.parseInt(s[4]),
                               Integer.parseInt(s[1]), Integer.parseInt(s[2]));
        }
      }
      else if (type == Insets.class) {
        if (s.length >= 5) {
          //noinspection UseDPIAwareInsets
          return new Insets(Integer.parseInt(s[1]), Integer.parseInt(s[2]),
                            Integer.parseInt(s[4]), Integer.parseInt(s[4]));
        }
      }
      else if (type == Color.class) {
        if (s.length >= 5) {
          return new ColorUIResource(
            new Color(Integer.parseInt(s[1]), Integer.parseInt(s[2]), Integer.parseInt(s[3]), Integer.parseInt(s[4])));
        }
      }
      else if (type.getSimpleName().contains("ArrayTable")) {
        return "ArrayTable!";
      }
      throw new UnsupportedOperationException(type.toString());
    }
private static Object fromObject(Object o, Class<?> type)