protected List<ValidationException> testComponent( Type type, SegmentType.Field.Component profile) { List<ValidationException> exList = new ArrayList<>(); UsageInfo usage = new UsageInfo(profile); exList.addAll(testType(type, profile.getDatatype(), usage, null)); // test children try { if (profile.getSubComponents().size() > 0 && !usage.disallowed() && !isEmpty(type)) { if (Composite.class.isAssignableFrom(type.getClass())) { Composite comp = (Composite) type; if (validateChildren) { int i = 1; for (SegmentType.Field.Component.SubComponent subComponent : profile.getSubComponents()) { UsageInfo scUsage = new UsageInfo(subComponent); try { Type sub = comp.getComponent(i - 1); exList.addAll(testType(sub, subComponent.getDatatype(), scUsage, null)); } catch (DataTypeException de) { profileNotHL7Compliant(exList, SUBCOMPONENT_TYPE_MISMATCH, type.getName(), i); } ++i; } } exList.addAll(checkUndefinedComponents(comp, profile.getSubComponents().size())); } else { profileViolatedWhen(true, exList, WRONG_COMPONENT_TYPE, type.getClass().getName()); } } } catch (HL7Exception e) { exList.add(new ValidationException(e)); } return exList; }