@Override public void printValue(String label, @Nullable Object value) { if (value != null && value.getClass().isArray()) { value = CollectionUtils.arrayToList(value); } writer.println(String.format("%17s = %s", label, value)); } });
/** * Render the inner '{@code option}' tags using the {@link #optionSource}. * @see #doRenderFromCollection(java.util.Collection, TagWriter) */ private void renderFromArray(TagWriter tagWriter) throws JspException { doRenderFromCollection(CollectionUtils.arrayToList(this.optionSource), tagWriter); }
/** * Render the inner '{@code option}' tags using the {@link #optionSource}. * @see #doRenderFromCollection(java.util.Collection, TagWriter) */ private void renderFromEnum(TagWriter tagWriter) throws JspException { doRenderFromCollection(CollectionUtils.arrayToList(((Class<?>) this.optionSource).getEnumConstants()), tagWriter); }
/** * Returns given object as {@link Collection}. Will return the {@link Collection} as is if the source is a * {@link Collection} already, will convert an array into a {@link Collection} or simply create a single element * collection for everything else. * * @param source * @return */ private static Collection<?> asCollection(Object source) { if (source instanceof Collection) { return (Collection<?>) source; } return source.getClass().isArray() ? CollectionUtils.arrayToList(source) : Collections.singleton(source); }
/** * Render the inner '{@code option}' tags using the {@link #optionSource}. * @see #doRenderFromCollection(java.util.Collection, TagWriter) */ private void renderFromArray(TagWriter tagWriter) throws JspException { doRenderFromCollection(CollectionUtils.arrayToList(this.optionSource), tagWriter); }
/** * Render the inner '{@code option}' tags using the {@link #optionSource}. * @see #doRenderFromCollection(java.util.Collection, TagWriter) */ private void renderFromEnum(TagWriter tagWriter) throws JspException { doRenderFromCollection(CollectionUtils.arrayToList(((Class<?>) this.optionSource).getEnumConstants()), tagWriter); }
/** * Returns the given object as {@link Collection}. Will do a copy of it if it implements {@link Iterable} or is an * array. Will return an empty {@link Collection} in case {@literal null} is given. Will wrap all other types into a * single-element collection. * * @param source * @return */ private static Collection<?> asCollection(@Nullable Object source) { if (source instanceof Iterable) { List<Object> result = new ArrayList<Object>(); for (Object element : (Iterable<?>) source) { result.add(element); } return result; } if (source == null) { return Collections.emptySet(); } return source.getClass().isArray() ? CollectionUtils.arrayToList(source) : Collections.singleton(source); }
boolean ignoreDefaultValue, String... ignoreAttributeNames) { Set<String> ignoreAttributeNamesSet = new HashSet<String>(arrayToList(ignoreAttributeNames));
boolean ignoreDefaultValue, String... ignoreAttributeNames) { Set<String> ignoreAttributeNamesSet = new HashSet<String>(arrayToList(ignoreAttributeNames));
@SuppressWarnings("unchecked") private static Object doGenerate(KeyGenerator keyGenerator, CacheKeyInvocationContext<?> context) { List<Object> parameters = new ArrayList<>(); for (CacheInvocationParameter param : context.getKeyParameters()) { Object value = param.getValue(); if (param.getParameterPosition() == context.getAllParameters().length - 1 && context.getMethod().isVarArgs()) { parameters.addAll((List<Object>) CollectionUtils.arrayToList(value)); } else { parameters.add(value); } } return keyGenerator.generate(context.getTarget(), context.getMethod(), parameters.toArray()); }
if (candidateValue != null) { if (boundValue.getClass().isArray()) { selected = collectionCompare(CollectionUtils.arrayToList(boundValue), candidateValue, bindStatus);
@SuppressWarnings("unchecked") private static Object doGenerate(KeyGenerator keyGenerator, CacheKeyInvocationContext<?> context) { List<Object> parameters = new ArrayList<>(); for (CacheInvocationParameter param : context.getKeyParameters()) { Object value = param.getValue(); if (param.getParameterPosition() == context.getAllParameters().length - 1 && context.getMethod().isVarArgs()) { parameters.addAll((List<Object>) CollectionUtils.arrayToList(value)); } else { parameters.add(value); } } return keyGenerator.generate(context.getTarget(), context.getMethod(), parameters.toArray()); }
if (candidateValue != null) { if (boundValue.getClass().isArray()) { selected = collectionCompare(CollectionUtils.arrayToList(boundValue), candidateValue, bindStatus);
iterable = (Iterable<?>) propertyValue; } else if (propertyValue.getClass().isArray()) { iterable = CollectionUtils.arrayToList(propertyValue); } else { throw new RuntimeException("Don't know how to handle " + propertyValue.getClass() + " type of collection");
public int baseUpdateStatus4Complete(String transOrderId) { TransOrder transOrder = new TransOrder(); transOrder.setTransOrderId(transOrderId); transOrder.setStatus(PayConstant.TRANS_STATUS_COMPLETE); TransOrderExample example = new TransOrderExample(); TransOrderExample.Criteria criteria = example.createCriteria(); criteria.andTransOrderIdEqualTo(transOrderId); List values = CollectionUtils.arrayToList(new Byte[] { PayConstant.TRANS_STATUS_SUCCESS, PayConstant.TRANS_STATUS_FAIL }); criteria.andStatusIn(values); return transOrderMapper.updateByExampleSelective(transOrder, example); }
public int baseUpdateStatus4Complete(String refundOrderId) { RefundOrder refundOrder = new RefundOrder(); refundOrder.setRefundOrderId(refundOrderId); refundOrder.setStatus(PayConstant.REFUND_STATUS_COMPLETE); RefundOrderExample example = new RefundOrderExample(); RefundOrderExample.Criteria criteria = example.createCriteria(); criteria.andRefundOrderIdEqualTo(refundOrderId); List values = CollectionUtils.arrayToList(new Byte[] { PayConstant.REFUND_STATUS_SUCCESS, PayConstant.REFUND_STATUS_FAIL }); criteria.andStatusIn(values); return refundOrderMapper.updateByExampleSelective(refundOrder, example); }
} else if (propertyValue.getClass().isArray()) { writeCollection(keyspace, propertyStringPath, CollectionUtils.arrayToList(propertyValue), persistentProperty.getTypeInformation().getRequiredComponentType(), sink); } else {
public Collection<String> split(String[] payload) { return CollectionUtils.arrayToList(payload); } }
@Test public void validateAllowAsCollectionOfString() { HeaderMapper<HttpHeaders> mapper = DefaultHttpHeaderMapper.inboundMapper(); Map<String, Object> messageHeaders = new HashMap<String, Object>(); messageHeaders.put("Allow", CollectionUtils.arrayToList(new String[] { "GET", "POST" })); HttpHeaders headers = new HttpHeaders(); mapper.fromHeaders(new MessageHeaders(messageHeaders), headers); assertEquals(2, headers.getAllow().size()); assertTrue(headers.getAllow().contains(HttpMethod.GET)); assertTrue(headers.getAllow().contains(HttpMethod.POST)); }
@Test public void validateAllowAsCollectionOfHttpMethods() { HeaderMapper<HttpHeaders> mapper = DefaultHttpHeaderMapper.inboundMapper(); Map<String, Object> messageHeaders = new HashMap<String, Object>(); messageHeaders.put("Allow", CollectionUtils.arrayToList(new HttpMethod[] { HttpMethod.GET, HttpMethod.POST })); HttpHeaders headers = new HttpHeaders(); mapper.fromHeaders(new MessageHeaders(messageHeaders), headers); assertEquals(2, headers.getAllow().size()); assertTrue(headers.getAllow().contains(HttpMethod.GET)); assertTrue(headers.getAllow().contains(HttpMethod.POST)); }