ServiceTypePackageVerifier { public boolean hasPackage(ServiceType serviceType, String eventPackage) { for (Object obj : serviceType.getPackages().getPackageAndAny()) { JAXBElement element = (JAXBElement) obj; if (element.getName().getLocalPart().equals("package") && element.getValue().equals(eventPackage)) { return true; } } return false; }  boolean hasPackage(ServiceType serviceType, String eventPackage);  }
@Test public void test() throws JAXBException, IOException { InputStream is = ServiceTypePackageVerifierTest.class .getResourceAsStream("rls-services-example.xml"); JAXBContext context = JAXBContext.newInstance("org.openxdm.xcap.client.appusage.rlsservices.jaxb"); Unmarshaller unmarshaller = context.createUnmarshaller(); RlsServices rlsServices = (RlsServices) unmarshaller.unmarshal(is); is.close(); Assert .assertTrue(new ServiceTypePackageVerifier().hasPackage(rlsServices.getService().get(0), "presence")); }