/** * <p> * Adds the specified string list header, joined together separated with * commas, to the specified request. * This method will not add a string list header if the specified values * are <code>null</code> or empty. * </p> * * @param request * The request to add the header to. * @param header * The header name. * @param values * The list of strings to join together for the header value. */ private static void addStringListHeader(Request<?> request, String header, List<String> values) { if (values != null && !values.isEmpty()) { request.addHeader(header, ServiceUtils.join(values)); } }
/** * <p> * Adds the specified string list header, joined together separated with * commas, to the specified request. This method will not add a string list * header if the specified values are <code>null</code> or empty. * </p> * * @param request The request to add the header to. * @param header The header name. * @param values The list of strings to join together for the header value. */ private static void addStringListHeader(Request<?> request, String header, List<String> values) { if (values != null && !values.isEmpty()) { request.addHeader(header, ServiceUtils.join(values)); } }
@Test public void testJoin() { final ServiceUtils utils = new ServiceUtils(); final List<String> list = new ArrayList<String>(); final String one = "1"; list.add(one); assertEquals("1", ServiceUtils.join(list)); final String two = "2"; list.add(two); assertEquals("1, 2", ServiceUtils.join(list)); final String three = "3"; list.add(three); assertEquals("1, 2, 3", ServiceUtils.join(list)); }
/** * <p> * Adds the specified string list header, joined together separated with * commas, to the specified request. This method will not add a string list * header if the specified values are <code>null</code> or empty. * </p> * * @param request The request to add the header to. * @param header The header name. * @param values The list of strings to join together for the header value. */ private static void addStringListHeader(Request<?> request, String header, List<String> values) { if (values != null && !values.isEmpty()) { request.addHeader(header, ServiceUtils.join(values)); } }
/** * <p> * Adds the specified string list header, joined together separated with * commas, to the specified request. * This method will not add a string list header if the specified values * are <code>null</code> or empty. * </p> * * @param request * The request to add the header to. * @param header * The header name. * @param values * The list of strings to join together for the header value. */ private static void addStringListHeader(Request<?> request, String header, List<String> values) { if (values != null && !values.isEmpty()) { request.addHeader(header, ServiceUtils.join(values)); } }