@SuppressWarnings("unchecked")
    <T> T get(@NotNull Class<T> type, @Nullable Rectangle screen) {
      Point location = apply(Point::new, myLocation);
      Dimension size = apply(Dimension::new, mySize);
      // convert location and size according to the given screen
      if (myScreen != null && !myScreen.isEmpty() && screen != null && !screen.isEmpty()) {
        if (location != null) ScreenUtil.moveAndScale(location, myScreen, screen);
        if (size != null) ScreenUtil.moveAndScale(size, myScreen, screen);
        if (!isVisible(location, size)) return null; // adjusted state is not visible
      }
      if (type == Point.class) return (T)location;
      if (type == Dimension.class) return (T)size;
      if (type == Rectangle.class) return location == null || size == null ? null : (T)new Rectangle(location, size);
      if (type != WindowState.class) throw new IllegalArgumentException();
      // copy a current state
      WindowStateBean state = new WindowStateBean();
      state.setLocation(location);
      state.setSize(size);
      state.setExtendedState(myMaximized ? Frame.MAXIMIZED_BOTH : Frame.NORMAL);
      state.setFullScreen(myFullScreen);
      return (T)state;
    }
@SuppressWarnings("unchecked")
    <T> T get(@NotNull Class<T> type, @Nullable Rectangle screen)