1 /* 2 * Copyright (C) 2007 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.dexgen.rop.type; 18 19 /** 20 * List of {@link Type} instances (or of things that contain types). 21 */ 22 public interface TypeList { 23 /** 24 * Returns whether this instance is mutable. Note that the 25 * {@code TypeList} interface itself doesn't provide any 26 * means of mutation, but that doesn't mean that there isn't an 27 * extra-interface way of mutating an instance. 28 * 29 * @return {@code true} if this instance is mutable or 30 * {@code false} if it is immutable 31 */ isMutable()32 public boolean isMutable(); 33 34 /** 35 * Gets the size of this list. 36 * 37 * @return {@code >= 0;} the size 38 */ size()39 public int size(); 40 41 /** 42 * Gets the indicated element. It is an error to call this with the 43 * index for an element which was never set; if you do that, this 44 * will throw {@code NullPointerException}. 45 * 46 * @param n {@code >= 0, < size();} which element 47 * @return {@code non-null;} the indicated element 48 */ getType(int n)49 public Type getType(int n); 50 51 /** 52 * Gets the number of 32-bit words required to hold instances of 53 * all the elements of this list. This is a sum of the widths (categories) 54 * of all the elements. 55 * 56 * @return {@code >= 0;} the required number of words 57 */ getWordCount()58 public int getWordCount(); 59 60 /** 61 * Returns a new instance which is identical to this one, except that 62 * the given item is appended to the end and it is guaranteed to be 63 * immutable. 64 * 65 * @param type {@code non-null;} item to append 66 * @return {@code non-null;} an appropriately-constructed instance 67 */ withAddedType(Type type)68 public TypeList withAddedType(Type type); 69 } 70