1 /*
2  * Copyright (C) 2010 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.cts.apicoverage;
18 
19 import java.util.ArrayList;
20 import java.util.Collections;
21 import java.util.List;
22 
23 /** Representation of a method in the API with parameters (arguments) and a return value. */
24 class ApiMethod implements Comparable<ApiMethod> {
25 
26     private final String mName;
27 
28     private final List<String> mParameterTypes;
29 
30     private final String mReturnType;
31 
32     private final boolean mDeprecated;
33 
34     private final String mVisibility;
35 
36     private final boolean mStaticMethod;
37 
38     private final boolean mFinalMethod;
39 
40     private final boolean mAbstractMethod;
41 
42     private boolean mIsCovered;
43 
ApiMethod( String name, List<String> parameterTypes, String returnType, boolean deprecated, String visibility, boolean staticMethod, boolean finalMethod, boolean abstractMethod)44     ApiMethod(
45             String name,
46             List<String> parameterTypes,
47             String returnType,
48             boolean deprecated,
49             String visibility,
50             boolean staticMethod,
51             boolean finalMethod,
52             boolean abstractMethod) {
53         mName = name;
54         mParameterTypes = new ArrayList<String>(parameterTypes);
55         mReturnType = returnType;
56         mDeprecated = deprecated;
57         mVisibility = visibility;
58         mStaticMethod = staticMethod;
59         mFinalMethod = finalMethod;
60         mAbstractMethod = abstractMethod;
61     }
62 
63     @Override
compareTo(ApiMethod another)64     public int compareTo(ApiMethod another) {
65         return mName.compareTo(another.mName);
66     }
67 
getName()68     public String getName() {
69         return mName;
70     }
71 
getParameterTypes()72     public List<String> getParameterTypes() {
73         return Collections.unmodifiableList(mParameterTypes);
74     }
75 
getReturnType()76     public String getReturnType() {
77         return mReturnType;
78     }
79 
isDeprecated()80     public boolean isDeprecated() {
81         return mDeprecated;
82     }
83 
isCovered()84     public boolean isCovered() {
85         return mIsCovered;
86     }
87 
getVisibility()88     public String getVisibility() { return mVisibility; }
89 
isAbstractMethod()90     public boolean isAbstractMethod() { return mAbstractMethod; }
91 
isStaticMethod()92     public boolean isStaticMethod() { return mStaticMethod; }
93 
isFinalMethod()94     public boolean isFinalMethod() { return mFinalMethod; }
95 
setCovered(boolean covered)96     public void setCovered(boolean covered) {
97         mIsCovered = covered;
98     }
99 }