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