public @Nullable <T extends PaletteItem> T getActiveItem(Class<T> cls) {
    PaletteItem item = getActiveItem();
    if (item != null && item.getClass().isInstance(item)) {
      //noinspection unchecked
      return (T)item;
    }
    return null;
  }
public @Nullable <T extends PaletteItem> T getActiveItem(Class<T> cls)