Debian Codegraph @

chunkio-processor/src/com/android/tools/chunkio/reader/CollectionChunkReader.java

raw
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
17 package com.android.tools.chunkio.reader;
18
19 import com.android.tools.chunkio.processor.FieldChunk;
20 import com.android.tools.chunkio.codegen.MethodDef;
21
22 import javax.lang.model.element.TypeElement;
23 import javax.lang.model.type.TypeMirror;
24 import java.util.List;
25
26 /**
27 * Tag interface to indicate that a chunk reader can
28 * read collections. Unlike other tag interfaces defined
29 * in this package, this one defines a few methods.
30 */
31 public interface CollectionChunkReader {
32 /**
33 * Indicates whether this reader's collection type can accept
34 * the supplied list of parameters. For instance, a reader
35 * that reads maps will not accept lists of parameters that
36 * do not have exactly two types.
37 *
38 * @param parameters List of parameter types
39 */
40 boolean acceptTypeParameters(List<TypeElement> parameters);
41
42 /**
43 * Emits the code that will read an element for this reader's
44 * collection and add it to that collection.
45 *
46 * @param builder The method builder where to add the generated code
47 * @param target The generated name of the instance holding the collection
48 * @param chunk The field chunk describing the annotated collection
49 * @param elementName The generated name of the variable to add to the collection
50 */
51 void pushElement(MethodDef.Builder builder, String target, FieldChunk chunk, String elementName);
52
53 /**
54 * Returns the type of the values held by the collections
55 * this reader can read.
56 */
57 TypeMirror getElementType();
58 }