1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
content / public / android / java / src / org / chromium / content_public / browser / SelectionMenuGroup.java [blame]
// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.content_public.browser;
import androidx.annotation.IdRes;
import java.util.Collection;
import java.util.SortedSet;
import java.util.TreeSet;
/** Data class representing a group in the text selection menu. */
public final class SelectionMenuGroup implements Comparable<SelectionMenuGroup> {
public final @IdRes int id;
public final int order;
public final SortedSet<SelectionMenuItem> items;
public SelectionMenuGroup(int id, int order) {
this.id = id;
this.order = order;
items = new TreeSet<>();
}
public void addItem(SelectionMenuItem item) {
items.add(item);
}
public void addItems(Collection<SelectionMenuItem> items) {
this.items.addAll(items);
}
/** Allows usage with {@link SortedSet} sorting. */
@Override
public int compareTo(SelectionMenuGroup otherGroup) {
return order - otherGroup.order;
}
}