1/*
2 * Copyright (C) 2015 The Android Open Source Project
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *      http://www.apache.org/licenses/LICENSE-2.0
7 * Unless required by applicable law or agreed to in writing, software
8 * distributed under the License is distributed on an "AS IS" BASIS,
9 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 * See the License for the specific language governing permissions and
11 * limitations under the License.
12 */
13
14package android.databinding.tool.reflection.java;
15
16import android.databinding.Bindable;
17import android.databinding.tool.reflection.ModelClass;
18import android.databinding.tool.reflection.ModelField;
19
20import java.lang.reflect.Field;
21import java.lang.reflect.Modifier;
22
23public class JavaField extends ModelField {
24    public final Field mField;
25
26    public JavaField(Field field) {
27        mField = field;
28    }
29
30    @Override
31    public boolean isBindable() {
32        return mField.getAnnotation(Bindable.class) != null;
33    }
34
35    @Override
36    public String getName() {
37        return mField.getName();
38    }
39
40    @Override
41    public boolean isPublic() {
42        return Modifier.isPublic(mField.getModifiers());
43    }
44
45    @Override
46    public boolean isStatic() {
47        return Modifier.isStatic(mField.getModifiers());
48    }
49
50    @Override
51    public boolean isFinal() {
52        return Modifier.isFinal(mField.getModifiers());
53    }
54
55    @Override
56    public ModelClass getFieldType() {
57        return new JavaClass(mField.getType());
58    }
59}
60