/** * Note that this method does not work on HL7.org structures */ public static <T extends IElement> List<T> allPopulatedChildElements(Class<T> theType, Object... theElements) { ArrayList<T> retVal = new ArrayList<T>(); for (Object next : theElements) { if (next == null) { continue; }else if (next instanceof IElement) { addElement(retVal, (IElement) next, theType); } else if (next instanceof List) { for (Object nextElement : ((List<?>)next)) { if (!(nextElement instanceof IBase)) { throw new IllegalArgumentException("Found element of "+nextElement.getClass()); } addElement(retVal, (IElement) nextElement, theType); } } else { throw new IllegalArgumentException("Found element of "+next.getClass()); } } return retVal; }
/** * Note that this method does not work on HL7.org structures */ public static <T extends IElement> List<T> allPopulatedChildElements(Class<T> theType, Object... theElements) { ArrayList<T> retVal = new ArrayList<T>(); for (Object next : theElements) { if (next == null) { continue; }else if (next instanceof IElement) { addElement(retVal, (IElement) next, theType); } else if (next instanceof List) { for (Object nextElement : ((List<?>)next)) { if (!(nextElement instanceof IBase)) { throw new IllegalArgumentException("Found element of "+nextElement.getClass()); } addElement(retVal, (IElement) nextElement, theType); } } else { throw new IllegalArgumentException("Found element of "+next.getClass()); } } return retVal; }