1 /*
2  * Copyright (C) 2023 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.telecom.cts.apps;
18 
19 import java.util.Objects;
20 
21 
22 public abstract class BaseTransaction {
getResult()23     public TestAppTransaction getResult() {
24         return mResult;
25     }
26 
getTestAppException()27     public TestAppException getTestAppException() {
28         return mException;
29     }
30 
isTransactionSuccessful()31     public boolean isTransactionSuccessful() {
32         return mResult.equals(TestAppTransaction.Success);
33     }
34 
35     TestAppTransaction mResult;
36     TestAppException mException;
37 
38     @Override
toString()39     public String toString() {
40         StringBuilder sb = new StringBuilder();
41 
42         sb.append("{ NoDataTransaction: [mResult: ")
43                 .append(mResult)
44                 .append("], [mException: ")
45                 .append(mException)
46                 .append("]  }");
47 
48         return sb.toString();
49     }
50 
51     /**
52      * {@inheritDoc}
53      */
54     @Override
equals(Object obj)55     public boolean equals(Object obj) {
56         if (obj == null || !(obj instanceof BaseTransaction)) {
57             return false;
58         }
59         BaseTransaction that = (BaseTransaction) obj;
60         return this.mResult == that.mResult
61                 && this.mException == that.mException;
62     }
63 
64     /**
65      * {@inheritDoc}
66      */
67     @Override
hashCode()68     public int hashCode() {
69         return Objects.hash(mResult, mException);
70     }
71 }
72