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 import org.jetbrains.annotations.Nullable; 19 20 public class Callable { 21 public enum Type { 22 METHOD, 23 FIELD 24 } 25 26 public static final int DYNAMIC = 1; 27 public static final int CAN_BE_INVALIDATED = 1 << 1; 28 public static final int STATIC = 1 << 2; 29 30 public final Type type; 31 32 public final String name; 33 34 public final String setterName; 35 36 public final ModelClass resolvedType; 37 38 @Nullable 39 public final ModelMethod method; 40 41 private final int mFlags; 42 43 private final int mParameterCount; 44 Callable(Type type, String name, String setterName, ModelClass resolvedType, int parameterCount, int flags, ModelMethod method)45 public Callable(Type type, String name, String setterName, ModelClass resolvedType, 46 int parameterCount, int flags, ModelMethod method) { 47 this.type = type; 48 this.name = name; 49 this.resolvedType = resolvedType; 50 mParameterCount = parameterCount; 51 this.setterName = setterName; 52 mFlags = flags; 53 this.method = method; 54 } 55 getTypeCodeName()56 public String getTypeCodeName() { 57 return resolvedType.toJavaCode(); 58 } 59 getParameterCount()60 public int getParameterCount() { 61 return mParameterCount; 62 } 63 isDynamic()64 public boolean isDynamic() { 65 return (mFlags & DYNAMIC) != 0; 66 } 67 isStatic()68 public boolean isStatic() { 69 return (mFlags & STATIC) != 0; 70 } 71 canBeInvalidated()72 public boolean canBeInvalidated() { 73 return (mFlags & CAN_BE_INVALIDATED) != 0; 74 } 75 getMinApi()76 public int getMinApi() { 77 return 1; 78 } 79 80 @Override toString()81 public String toString() { 82 return "Callable{" + 83 "type=" + type + 84 ", name='" + name + '\'' + 85 ", resolvedType=" + resolvedType + 86 ", isDynamic=" + isDynamic() + 87 ", canBeInvalidated=" + canBeInvalidated() + 88 ", static=" + isStatic() + 89 ", method=" + method + 90 '}'; 91 } 92 } 93