• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2015 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 package android.databinding.tool.reflection;
17 
18 public class Callable {
19 
20     public enum Type {
21         METHOD,
22         FIELD
23     }
24 
25     public static final int DYNAMIC = 1;
26     public static final int CAN_BE_INVALIDATED = 1 << 1;
27     public static final int STATIC = 1 << 2;
28 
29     public final Type type;
30 
31     public final String name;
32 
33     public final String setterName;
34 
35     public final ModelClass resolvedType;
36 
37     private final int mFlags;
38 
39     private final int mParameterCount;
40 
Callable(Type type, String name, String setterName, ModelClass resolvedType, int parameterCount, int flags)41     public Callable(Type type, String name, String setterName, ModelClass resolvedType,
42                     int parameterCount, int flags) {
43         this.type = type;
44         this.name = name;
45         this.resolvedType = resolvedType;
46         mParameterCount = parameterCount;
47         this.setterName = setterName;
48         mFlags = flags;
49     }
50 
getTypeCodeName()51     public String getTypeCodeName() {
52         return resolvedType.toJavaCode();
53     }
54 
getParameterCount()55     public int getParameterCount() {
56         return mParameterCount;
57     }
58 
isDynamic()59     public boolean isDynamic() {
60         return (mFlags & DYNAMIC) != 0;
61     }
62 
isStatic()63     public boolean isStatic() {
64         return (mFlags & STATIC) != 0;
65     }
66 
canBeInvalidated()67     public boolean canBeInvalidated() {
68         return (mFlags & CAN_BE_INVALIDATED) != 0;
69     }
70 
getMinApi()71     public int getMinApi() {
72         return 1;
73     }
74 
75     @Override
toString()76     public String toString() {
77         return "Callable{" +
78                 "type=" + type +
79                 ", name='" + name + '\'' +
80                 ", resolvedType=" + resolvedType +
81                 ", isDynamic=" + isDynamic() +
82                 ", canBeInvalidated=" + canBeInvalidated() +
83                 ", static=" + isStatic() +
84                 '}';
85     }
86 }
87