1 19 package org.netbeans.mdr.util; 20 21 import java.util.*; 22 23 28 public abstract class AbstractLazyList extends AbstractList { 29 private final Object innerList[]; 30 31 public AbstractLazyList() { 32 super(); 33 innerList = null; 34 } 35 36 public AbstractLazyList(Collection elements) { 37 super(); 38 innerList = elements.toArray(); 39 } 40 41 protected abstract Object wrap(Object o); 42 protected abstract boolean isWrapped(Object o); 43 44 public int size() { 45 return innerList.length; 46 } 47 48 public Object get(int p) { 49 if (!isWrapped(innerList[p])) synchronized (innerList) { 50 if (!isWrapped(innerList[p])) { 51 innerList[p] = wrap(innerList[p]); 52 } 53 } 54 55 return innerList[p]; 56 } 57 } 58 | Popular Tags |