/** * Will parse the body of all XML tags with the {@code tag} argument * into a {@link java.util.List} of {@link Object} using the supplied {@link BodyMarshaller}. * <pre> * {@code <names> * <name>Paul</name> * <name>Peter</name> * </names> * * ElementFinder<T> finder = getListFinder("name", marshallerOfT); * finder.find(element, "names"); * List<T> names = finder.getResultOrThrow(); * } * </pre> * * @param tag The tag to parse the body for each list element * @param bodyMarshaller The marshaller to parse the body into your required type * @param <T> The type you wish to create from the XML body * @return {@link ElementFinder} */ public <T> ElementFinder<List<T>> getListFinder(String tag, BodyMarshaller<T> bodyMarshaller) { return getTypeFinder(new ListParser<T>(tag, this, bodyMarshaller)); }
/** * Will parse the body of all XML tags with the {@code tag} argument * into a {@link java.util.List} of {@link Object}. This is a simple Integer wrapper class that * has a constructor that takes a single {@link Integer} parameter.<br/> * See {@link #getIntegerWrapperTypeFinder(Class)} for more info. * * @param tag The tag to parse the body for each list element * @param clazz The class of the wrapper type you wish your List to be made of * @param <T> The type you wish to create from the XML body * @return {@link ElementFinder} */ public <T> ElementFinder<List<T>> getIntegerWrapperTypeListFinder(String tag, Class<T> clazz) { return getTypeFinder(new ListParser<T>(tag, this, getIntegerWrapperMarshaller(clazz))); }
/** * Will parse the body of all XML tags with the {@code tag} argument * into a {@link java.util.List} of {@link Object}. This is a simple String wrapper class that * has a constructor that takes a single {@link String} parameter.<br/> * See {@link #getStringWrapperTypeFinder(Class)} for more info. * * @param tag The tag to parse the body for each list element * @param clazz The class of the wrapper type you wish your List to be made of * @param <T> The type you wish to create from the XML body * @return {@link ElementFinder} */ public <T> ElementFinder<List<T>> getStringWrapperTypeListFinder(String tag, Class<T> clazz) { return getTypeFinder(new ListParser<T>(tag, this, getStringWrapperMarshaller(clazz))); }
@Before public void setUp() { initMocks(this); stub(mockFactory.getListElementFinder(Mockito.<BodyMarshaller<Object>>any(), Mockito.<ParseWatcher<Object>>any())).toReturn(mockListCreator); listParser = new ListParser<Object>("individualItemTag", mockFactory, mockMarshaller); }