/** * Factory method to create a SetList using the supplied list to retain order. * <p> * If the list contains duplicates, these are removed (first indexed one kept). * A <code>HashSet</code> is used for the set behaviour. * * @param list the list to decorate, must not be null * @throws IllegalArgumentException if list is null */ public static SetUniqueList decorate(java.util.List <Object> list) { if (list == null) { throw new java.lang.IllegalArgumentException("List must not be null"); } if (list.isEmpty()) { return(new SetUniqueList(list, new java.util.HashSet <Object>())); } else { java.util.List <Object> temp = new java.util.ArrayList <Object>(list); list.clear(); SetUniqueList sl = new SetUniqueList(list, new java.util.HashSet <Object>()); sl.addAll(temp); return(sl); } }
/** * Factory method to create a SetList using the supplied list to retain order. * <p> * If the list contains duplicates, these are removed (first indexed one kept). * A <code>HashSet</code> is used for the set behaviour. * * @param list the list to decorate, must not be null * @throws IllegalArgumentException if list is null */ public static SetUniqueList decorate(java.util.List<Object> list) { if (list == null) { throw new java.lang.IllegalArgumentException("List must not be null"); } if (list.isEmpty()) { return new SetUniqueList(list, new java.util.HashSet<Object>()); } else { java.util.List<Object> temp = new java.util.ArrayList<Object>(list); list.clear(); SetUniqueList sl = new SetUniqueList(list, new java.util.HashSet<Object>()); sl.addAll(temp); return sl; } }