1 /* 2 * Copyright (C) 2024 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 package com.android.internal.widget.remotecompose.core.operations.utilities; 17 18 import android.annotation.Nullable; 19 20 /** 21 * interface to allow expressions to access collections Todo define a convention for when access is 22 * unavailable 23 */ 24 public interface CollectionsAccess { 25 26 /** 27 * Get the float value in the array at the given index 28 * 29 * @param id the id of the float array 30 * @param index the index of the value 31 * @return 32 */ getFloatValue(int id, int index)33 float getFloatValue(int id, int index); 34 35 /** 36 * Get the array of float if it is a float array 37 * 38 * @param id the id of the float array 39 * @return 40 */ 41 @Nullable getFloats(int id)42 float[] getFloats(int id); 43 44 /** 45 * Get the number of entries in the list 46 * 47 * @param id the id of the list 48 * @return 49 */ getListLength(int id)50 int getListLength(int id); 51 52 /** 53 * get the id of an entry if the list is a list of id's 54 * 55 * @param listId the list id 56 * @param index the index into the list 57 * @return 58 */ getId(int listId, int index)59 int getId(int listId, int index); 60 61 /** 62 * Get the value as an integer 63 * 64 * @param listId the list id to access 65 * @param index the index into the list 66 * @return 67 */ getIntValue(int listId, int index)68 default int getIntValue(int listId, int index) { 69 return (int) getFloatValue(listId, index); 70 } 71 } 72