ExtensionObjectMapper { public static <T> T getAnyElement(List<Object> anies, Class<T> classType) { for (Object any : anies) { LOG.debug("Class: " + any.getClass()); if (any instanceof Element) { Element element = (Element) any; try { JAXBContext jc = JAXBContext.newInstance(ObjectFactory.class.getPackage().getName()); Unmarshaller unmarshaller = jc.createUnmarshaller(); Object o = unmarshaller.unmarshal(element); if(classType.isInstance(o)) { return classType.cast(o); } } catch (JAXBException e) { e.printStackTrace(); } } } return null; }  static T getOtherAttribute(Map<QName, String> otherAttributes, String attributeName); static T getAnyElement(List<Object> anies, Class<T> classType);  }
@Test public void shouldUnmarshallAccessListFromAniesList() throws JAXBException, ParserConfigurationException, IOException, SAXException { AccessList accessList = ExtensionObjectMapper.getAnyElement(unMarshalledLb.getAnies(), AccessList.class); Assert.assertNotNull(accessList); Assert.assertEquals("1.1.1.1", accessList.getNetworkItems().get(0).getAddress()); Assert.assertEquals(IpVersion.IPV4, accessList.getNetworkItems().get(0).getIpVersion()); Assert.assertEquals(NetworkItemType.DENY, accessList.getNetworkItems().get(0).getType()); }