xref: /aosp_15_r20/cts/common/device-side/bedstead/queryable/src/main/java/com/android/queryable/queries/ListQuery.java (revision b7c941bb3fa97aba169d73cee0bed2de8ac964bf)
1 /*
2  * Copyright (C) 2021 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.queryable.queries;
18 
19 import com.android.queryable.Queryable;
20 
21 import java.util.Collection;
22 import java.util.List;
23 
24 /** Query for a {@link java.util.List}. */
25 public interface ListQuery<E extends Queryable, F> extends Query<List<F>> {
26 
27     /** Queries a {@link List}. */
list(Class<E> cls)28     static <E> ListQueryHelper.ListQueryBase<E> list(Class<E> cls) {
29         return new ListQueryHelper.ListQueryBase<E>();
30     }
31 
size()32     IntegerQuery<E> size();
33 
34     /**
35      * Used to query whether a list contains certain objects.
36      */
contains(Query<F>.... objects)37     E contains(Query<F>... objects);
38 
39     /**
40      * Used to query whether a list contains certain objects.
41      *
42      * <p>There are no bounds on the type for this method and therefore to find matches objects are
43      * compared using {@link Object#equals} If you are not checking for equality use
44      * {@link #contains(Query[])}.
45      */
contains(F... objects)46     E contains(F... objects);
47 
48     /**
49      * Used to query whether a list does not contain certain objects.
50      */
doesNotContain(Query<F>.... objects)51     E doesNotContain(Query<F>... objects);
52 
53     /**
54      * Used to query whether a list does not contain certain objects.
55      *
56      * <p>There are no bounds on the type for this method and therefore to find matches objects are
57      * compared using {@link Object#equals}. If you are not checking for equality use
58      * {@link #contains(Query[])}.
59      */
doesNotContain(F... objects)60     E doesNotContain(F... objects);
61 
62     /**
63      * Used to query whether a list contains all of the elements from a collection.
64      *
65      * <p>There are no bounds on the type for this method and therefore to find matches objects are
66      * compared using {@link Object#equals} If you are not checking for equality use
67      * {@link #contains(Query[])}.
68      */
containsAll(H... collection)69     <H extends Collection<F>> E containsAll(H... collection);
70 
71     /**
72      * Used to query whether a list does not contain any elements given in a collection.
73      *
74      * <p>There are no bounds on the type for this method and therefore to find matches objects are
75      * compared using {@link Object#equals} If you are not checking for equality use
76      * {@link #contains(Query[])}.
77      */
doesNotContainAny(H... collections)78     <H extends Collection<F>> E doesNotContainAny(H... collections);
79 
80     /**
81      * Used to query whether a list contains exactly certain objects only.
82      */
containsExactly(F... objects)83     E containsExactly(F... objects);
84 }
85