• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2017 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 android.app.servertransaction;
18 
19 import android.annotation.NonNull;
20 import android.app.ClientTransactionHandler;
21 
22 /**
23  * Base interface for individual requests from server to client.
24  * Each of them can be prepared before scheduling and, eventually, executed.
25  *
26  * @hide
27  */
28 public interface BaseClientRequest {
29 
30     /**
31      * Prepares the client request before scheduling.
32      * An example of this might be informing about pending updates for some values.
33      *
34      * @param client target client handler.
35      */
preExecute(@onNull ClientTransactionHandler client)36     default void preExecute(@NonNull ClientTransactionHandler client) {
37     }
38 
39     /**
40      * Executes the request.
41      *
42      * @param client         target client handler.
43      * @param pendingActions container that may have data pending to be used.
44      */
execute(@onNull ClientTransactionHandler client, @NonNull PendingTransactionActions pendingActions)45     void execute(@NonNull ClientTransactionHandler client,
46             @NonNull PendingTransactionActions pendingActions);
47 
48     /**
49      * Performs all actions that need to happen after execution, e.g. report the result to server.
50      *
51      * @param client         target client handler.
52      * @param pendingActions container that may have data pending to be used.
53      */
postExecute(@onNull ClientTransactionHandler client, @NonNull PendingTransactionActions pendingActions)54     default void postExecute(@NonNull ClientTransactionHandler client,
55             @NonNull PendingTransactionActions pendingActions) {
56     }
57 }
58