1/*
2 * Copyright (C) 2016 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
17package android.databinding.tool.reflection;
18
19import java.util.Map;
20
21/**
22 * A class that can be used by ModelAnalyzer without any backing model. This is used
23 * for fields on ViewDataBinding subclasses that haven't been generated yet.
24 *
25 * @see ModelAnalyzer#injectViewDataBinding(String, Map, Map)
26 */
27public class InjectedField extends ModelField {
28    private final String mType;
29    private final String mName;
30
31    public InjectedField(String name, String type) {
32        mName = name;
33        mType = type;
34    }
35
36    @Override
37    public boolean isBindable() {
38        return false;
39    }
40
41    @Override
42    public String getName() {
43        return mName;
44    }
45
46    @Override
47    public boolean isPublic() {
48        return true;
49    }
50
51    @Override
52    public boolean isStatic() {
53        return false;
54    }
55
56    @Override
57    public boolean isFinal() {
58        return true;
59    }
60
61    @Override
62    public ModelClass getFieldType() {
63        return ModelAnalyzer.getInstance().findClass(mType, null);
64    }
65}
66