/** * Checks if the Loop contains the specified child Loop. It will check the complete child * hierarchy. * * @param name name of a child loop * @return boolean */ public boolean hasLoop(String name) { for (Loop l : this.childList()) { if (name.equals(l.getName())) { return true; } if (l.hasLoop(name)) { return true; } } return false; }
/** * Get the loop in the X12 transaction It will check the complete child hierarchy. * * @param name name of a loop * @return {@link java.util.List}<{@link Loop}> */ public List<Loop> findLoop(String name) { List<Loop> foundLoops = new ArrayList<Loop>(); for (Loop l : this.childList()) { if (name.equals(l.getName())) { foundLoops.add(l); } List<Loop> moreLoops = l.findLoop(name); if (moreLoops.size() > 0) { foundLoops.addAll(moreLoops); } } return foundLoops; }