11330f79f95fd14b53c393402fbcbf7b7bbdcbc60Deepanshu Gupta/* 21330f79f95fd14b53c393402fbcbf7b7bbdcbc60Deepanshu Gupta * Copyright (C) 2015 The Android Open Source Project 31330f79f95fd14b53c393402fbcbf7b7bbdcbc60Deepanshu Gupta * 41330f79f95fd14b53c393402fbcbf7b7bbdcbc60Deepanshu Gupta * Licensed under the Apache License, Version 2.0 (the "License"); 51330f79f95fd14b53c393402fbcbf7b7bbdcbc60Deepanshu Gupta * you may not use this file except in compliance with the License. 61330f79f95fd14b53c393402fbcbf7b7bbdcbc60Deepanshu Gupta * You may obtain a copy of the License at 71330f79f95fd14b53c393402fbcbf7b7bbdcbc60Deepanshu Gupta * 81330f79f95fd14b53c393402fbcbf7b7bbdcbc60Deepanshu Gupta * http://www.apache.org/licenses/LICENSE-2.0 91330f79f95fd14b53c393402fbcbf7b7bbdcbc60Deepanshu Gupta * 101330f79f95fd14b53c393402fbcbf7b7bbdcbc60Deepanshu Gupta * Unless required by applicable law or agreed to in writing, software 111330f79f95fd14b53c393402fbcbf7b7bbdcbc60Deepanshu Gupta * distributed under the License is distributed on an "AS IS" BASIS, 121330f79f95fd14b53c393402fbcbf7b7bbdcbc60Deepanshu Gupta * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 131330f79f95fd14b53c393402fbcbf7b7bbdcbc60Deepanshu Gupta * See the License for the specific language governing permissions and 141330f79f95fd14b53c393402fbcbf7b7bbdcbc60Deepanshu Gupta * limitations under the License. 151330f79f95fd14b53c393402fbcbf7b7bbdcbc60Deepanshu Gupta */ 161330f79f95fd14b53c393402fbcbf7b7bbdcbc60Deepanshu Gupta 171330f79f95fd14b53c393402fbcbf7b7bbdcbc60Deepanshu Guptapackage com.android.tools.layoutlib.java; 181330f79f95fd14b53c393402fbcbf7b7bbdcbc60Deepanshu Gupta 191330f79f95fd14b53c393402fbcbf7b7bbdcbc60Deepanshu Guptaimport com.android.tools.layoutlib.create.ReplaceMethodCallsAdapter; 201330f79f95fd14b53c393402fbcbf7b7bbdcbc60Deepanshu Gupta 211330f79f95fd14b53c393402fbcbf7b7bbdcbc60Deepanshu Guptaimport java.util.Iterator; 221330f79f95fd14b53c393402fbcbf7b7bbdcbc60Deepanshu Guptaimport java.util.LinkedHashMap; 231330f79f95fd14b53c393402fbcbf7b7bbdcbc60Deepanshu Guptaimport java.util.Map; 241330f79f95fd14b53c393402fbcbf7b7bbdcbc60Deepanshu Guptaimport java.util.Map.Entry; 251330f79f95fd14b53c393402fbcbf7b7bbdcbc60Deepanshu Gupta 261330f79f95fd14b53c393402fbcbf7b7bbdcbc60Deepanshu Gupta/** 271330f79f95fd14b53c393402fbcbf7b7bbdcbc60Deepanshu Gupta * Provides alternate implementation to java.util.LinkedHashMap#eldest(), which is present as a 281330f79f95fd14b53c393402fbcbf7b7bbdcbc60Deepanshu Gupta * non-public method in the Android VM, but not present on the host VM. This is injected in the 291330f79f95fd14b53c393402fbcbf7b7bbdcbc60Deepanshu Gupta * layoutlib using {@link ReplaceMethodCallsAdapter}. 301330f79f95fd14b53c393402fbcbf7b7bbdcbc60Deepanshu Gupta */ 311330f79f95fd14b53c393402fbcbf7b7bbdcbc60Deepanshu Guptapublic class LinkedHashMap_Delegate { 321330f79f95fd14b53c393402fbcbf7b7bbdcbc60Deepanshu Gupta public static <K,V> Map.Entry<K,V> eldest(LinkedHashMap<K,V> map) { 331330f79f95fd14b53c393402fbcbf7b7bbdcbc60Deepanshu Gupta Iterator<Entry<K, V>> iterator = map.entrySet().iterator(); 341330f79f95fd14b53c393402fbcbf7b7bbdcbc60Deepanshu Gupta return iterator.hasNext() ? iterator.next() : null; 351330f79f95fd14b53c393402fbcbf7b7bbdcbc60Deepanshu Gupta } 361330f79f95fd14b53c393402fbcbf7b7bbdcbc60Deepanshu Gupta} 37