public static AdhocQueryType getAdhocQuery(Subscribe nhinSubscribe) { AdhocQueryType adhocQuery = null; List<Object> any = nhinSubscribe.getAny(); for (Object anyItem : any) { LOG.debug( "SubscribeTransformHelper.getAdhocQuery - type of any in list: " + anyItem.getClass().getName()); if (anyItem instanceof oasis.names.tc.ebxml_regrep.xsd.rim._3.AdhocQueryType) { LOG.debug("Any item was oasis.names.tc.ebxml_regrep.xsd.rim._3.AdhocQueryType"); adhocQuery = (AdhocQueryType) anyItem; } else if (anyItem instanceof JAXBElement) { LOG.debug("Any item was JAXBElement"); if (((JAXBElement) anyItem).getValue() instanceof AdhocQueryType) { LOG.debug("Any item - JAXBElement value was AdhocQueryType"); adhocQuery = (AdhocQueryType) ((JAXBElement) anyItem).getValue(); } } else if (anyItem instanceof Element) { LOG.debug("Any item was Element"); Element element = (Element) anyItem; LOG.debug( "SubscribeTransformHelper.getAdhocQuery - element name of any in list: " + element.getLocalName()); adhocQuery = unmarshalAdhocQuery(element); } else { LOG.debug("Any type did not fit any expected value"); } } return adhocQuery; }