public void switchMode(Mode nextMode, Field initialSortField,
    boolean keepSortFieldAndSortOrderIfPossible, @Nullable List<Field> initialFields,
    @Nullable Boolean initialAscendingSort, @Nullable List<RecordFilter> initialFilters) {
    currentMode = nextMode;
    fieldInfos = Collections.unmodifiableList(new ArrayList<>(currentMode.getFieldInfos()));

    if (initialFields != null) {
      List<Field> tmp = new ArrayList<>(initialFields);
      tmp.addAll(currentMode.getFieldInfos().stream().map(FieldInfo::getField)
        .filter(f -> !initialFields.contains(f)).collect(Collectors.toList()));
      fields = Collections.unmodifiableList(tmp);
    } else {
      fields = Collections.unmodifiableList(
        currentMode.getFieldInfos().stream().map(FieldInfo::getField).collect(Collectors.toList()));
    }

    if (keepSortFieldAndSortOrderIfPossible) {
      boolean match = fields.stream().anyMatch(f -> f == currentSortField);
      if (!match) {
        if (initialSortField != null && initialAscendingSort != null) {
          currentSortField = initialSortField;
          ascendingSort = initialAscendingSort;
        } else {
          currentSortField = nextMode.getDefaultSortField();
          ascendingSort = false;
        }
      }
    } else {
      if (initialSortField != null && initialAscendingSort != null) {
        currentSortField = initialSortField;
        ascendingSort = initialAscendingSort;
      } else {
        currentSortField = nextMode.getDefaultSortField();
        ascendingSort = false;
      }
    }

    clearFilters();
    if (initialFilters != null) {
      filters.addAll(initialFilters);
    }
    decomposePushDownFilter();
  }
The data and business logic for the top screen.
hbase-hbtop/src/main/java/org/apache/hadoop/hbase/hbtop/screen/top/TopScreenModel.java