ArgListExpr.java revision e9b33bac04bb1ce1444d7f1744fcec1ecd3a57da
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
17package android.databinding.tool.expr;
18
19import android.databinding.tool.reflection.ModelAnalyzer;
20import android.databinding.tool.reflection.ModelClass;
21
22import java.util.List;
23
24/**
25 * This is a special expression that is created when we have an adapter that has multiple
26 * parameters.
27 * <p>
28 * When it is detected, we create a new binding with this argument list expression and merge N
29 * bindings into a new one so that rest of the code generation logic works as expected.
30 */
31public class ArgListExpr extends Expr {
32    private int mId;
33    public ArgListExpr(int id, Iterable<Expr> children) {
34        super(children);
35        mId = id;
36    }
37
38    @Override
39    protected String computeUniqueKey() {
40        return "ArgList[" + mId + "]" + super.computeUniqueKey();
41    }
42
43    @Override
44    protected ModelClass resolveType(ModelAnalyzer modelAnalyzer) {
45        return modelAnalyzer.findClass(Void.class);
46    }
47
48    @Override
49    protected List<Dependency> constructDependencies() {
50        return super.constructDynamicChildrenDependencies();
51    }
52
53    @Override
54    public boolean canBeEvaluatedToAVariable() {
55        return false;
56    }
57}
58