Java Code Examples for org.springframework.util.CollectionUtils#arrayToList()
The following examples show how to use
org.springframework.util.CollectionUtils#arrayToList() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MockMvcResultHandlers.java From java-technology-stack with MIT License | 6 votes |
public PrintWriterPrintingResultHandler(final PrintWriter writer) { super(new ResultValuePrinter() { @Override public void printHeading(String heading) { writer.println(); writer.println(String.format("%s:", heading)); } @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)); } }); }
Example 2
Source File: MockMvcResultPrinter.java From hawkbit with Eclipse Public License 1.0 | 6 votes |
public ConsolePrintingResultHandler() { super(new ResultValuePrinter() { @Override public void printHeading(final String heading) { LOG.debug(String.format("%20s:", heading)); } @Override public void printValue(final String label, final Object v) { Object value = v; if (value != null && value.getClass().isArray()) { value = CollectionUtils.arrayToList(value); } LOG.debug(String.format("%20s = %s", label, value)); } }); }
Example 3
Source File: YcMockMvcResultHandlers.java From yes-cart with Apache License 2.0 | 6 votes |
public ConsolePrintingResultHandler() { super(new ResultValuePrinter() { private final Logger LOG = LoggerFactory.getLogger("RESTTEST"); @Override public void printHeading(String heading) { LOG.info(""); LOG.info(String.format("%20s:", heading)); } @Override public void printValue(String label, Object value) { if (value != null && value.getClass().isArray()) { value = CollectionUtils.arrayToList(value); } LOG.info(String.format("%20s = %s", label, value)); } }); }
Example 4
Source File: CLIOptionDefinition.java From FortifyBugTrackerUtility with MIT License | 6 votes |
public String getValue(Context context) { String result = getValueFromContext(context); if ( StringUtils.isBlank(result) ) { result = getDefaultValue(); context.put(getName(), result); } if ( StringUtils.isBlank(result) && isRequiredAndNotIgnored(context) ) { // TODO Clean this up @SuppressWarnings("unchecked") List<String> optionNames = new ArrayList<String>(CollectionUtils.arrayToList(getIsAlternativeForOptions())); optionNames.add(getName()); throw new IllegalArgumentException("Required CLI option "+StringUtils.join(optionNames, " or ")+" not defined"); } if ( StringUtils.isNotBlank(result) && allowedValues!=null && !allowedValues.containsKey(result) ) { throw new IllegalArgumentException("CLI option value "+result+" not allowed for option "+getName()); } return result; }
Example 5
Source File: MockMvcResultHandlers.java From spring4-understanding with Apache License 2.0 | 6 votes |
public PrintWriterPrintingResultHandler(final PrintWriter writer) { super(new ResultValuePrinter() { @Override public void printHeading(String heading) { writer.println(); writer.println(String.format("%s:", heading)); } @Override public void printValue(String label, Object value) { if (value != null && value.getClass().isArray()) { value = CollectionUtils.arrayToList(value); } writer.println(String.format("%17s = %s", label, value)); } }); }
Example 6
Source File: MockMvcResultHandlers.java From spring-analysis-note with MIT License | 6 votes |
public PrintWriterPrintingResultHandler(final PrintWriter writer) { super(new ResultValuePrinter() { @Override public void printHeading(String heading) { writer.println(); writer.println(String.format("%s:", heading)); } @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)); } }); }
Example 7
Source File: DemoController.java From spring-boot-starter-samples with Apache License 2.0 | 5 votes |
/** * 删除逻辑实现 */ @ApiOperation(value = "删除xxx信息", notes = "根据ID删除xxx", httpMethod = "POST") @ApiImplicitParam(name = "ids", value = "ID集合,多个使用,拼接", required = true, dataType = "String") @BusinessLog(module = LogConstant.Module.N01, business = LogConstant.BUSINESS.N010001, opt = BusinessType.DELETE) @PostMapping("delete") @ResponseBody public Object delete(@RequestParam(value = "ids") String ids, HttpServletRequest request) throws Exception { try { if (StringUtils.isEmpty(ids)) { return fail("I00002"); } List<String> list = CollectionUtils.arrayToList(StringUtils.tokenizeToStringArray(ids)); /*// 查询要删除的数据对应的依赖 List<Map<String, String>> dependencies = getDemoService().getDependencies(list); // 不为空,则表示有数据在被使用 if (!CollectionUtils.isEmpty(dependencies)) { // 解析依赖关系,组织描述信息 StringBuilder builder = new StringBuilder("存在未解除的依赖关系:【"); for (Map<String, String> hashMap : dependencies) { builder.append(hashMap.get("字段1")).append(" >> ").append(hashMap.get("字段2")) .append(","); } builder.deleteCharAt(builder.length() - 1); builder.append("】,无法删除."); return ResultUtils.statusMap(STATUS_FAIL, builder.toString()); }*/ // 批量删除数据库配置记录 getDemoService().batchDelete(list); return success("I99005"); } catch (Exception e) { logException(this, e); return fail("I99006"); } }
Example 8
Source File: SolrQueryMethod.java From dubbox with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") private List<String> getAnnotationValuesAsStringList(Annotation annotation, String attribute) { String[] values = (String[]) AnnotationUtils.getValue(annotation, attribute); if (values.length > 1 || (values.length == 1 && StringUtils.hasText(values[0]))) { return CollectionUtils.arrayToList(values); } return Collections.emptyList(); }
Example 9
Source File: SimpleSolrPersistentProperty.java From dubbox with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") @Override public Collection<String> getCopyFields() { Indexed indexedAnnotation = getIndexAnnotation(); if (indexedAnnotation != null) { if (indexedAnnotation.copyTo().length > 0) { return CollectionUtils.arrayToList(indexedAnnotation.copyTo()); } } return Collections.emptyList(); }
Example 10
Source File: MappingSolrConverter.java From dubbox with Apache License 2.0 | 5 votes |
private static Collection<?> asCollection(Object source) { if (source instanceof Collection) { return (Collection<?>) source; } return source.getClass().isArray() ? CollectionUtils.arrayToList(source) : Collections.singleton(source); }
Example 11
Source File: ValueUtil.java From spring-cloud-gcp with Apache License 2.0 | 5 votes |
public static Object toListIfArray(Object val) { if (val != null && isArrayOfItems(val.getClass())) { //if a property is an array, convert it to list return CollectionUtils.arrayToList(val); } return val; }
Example 12
Source File: BaseService4TransOrder.java From xxpay-master with MIT License | 5 votes |
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); }
Example 13
Source File: BaseService4RefundOrder.java From xxpay-master with MIT License | 5 votes |
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); }
Example 14
Source File: DemoController.java From spring-boot-starter-samples with Apache License 2.0 | 5 votes |
/** * 删除逻辑实现 */ @ApiOperation(value = "删除xxx信息", notes = "根据ID删除xxx", httpMethod = "POST") @ApiImplicitParam(name = "ids", value = "ID集合,多个使用,拼接", required = true, dataType = "String") @BusinessLog(module = LogConstant.Module.N01, business = LogConstant.BUSINESS.N010001, opt = BusinessType.DELETE) @PostMapping("delete") @ResponseBody public Object delete(@RequestParam(value = "ids") String ids, HttpServletRequest request) throws Exception { try { if (StringUtils.isEmpty(ids)) { return fail("I00002"); } List<String> list = CollectionUtils.arrayToList(StringUtils.tokenizeToStringArray(ids)); /*// 查询要删除的数据对应的依赖 List<Map<String, String>> dependencies = getDemoService().getDependencies(list); // 不为空,则表示有数据在被使用 if (!CollectionUtils.isEmpty(dependencies)) { // 解析依赖关系,组织描述信息 StringBuilder builder = new StringBuilder("存在未解除的依赖关系:【"); for (Map<String, String> hashMap : dependencies) { builder.append(hashMap.get("字段1")).append(" >> ").append(hashMap.get("字段2")) .append(","); } builder.deleteCharAt(builder.length() - 1); builder.append("】,无法删除."); return ResultUtils.statusMap(STATUS_FAIL, builder.toString()); }*/ // 批量删除数据库配置记录 getDemoService().batchDelete(list); return success("I99005"); } catch (Exception e) { logException(this, e); return fail("I99006"); } }
Example 15
Source File: MultiRegionParameterStorePropertySourceConfigurationStrategy.java From spring-boot-parameter-store-integration with MIT License | 5 votes |
private List<String> getRegions(ConfigurableEnvironment environment) { List<String> regions = CollectionUtils.arrayToList(environment.getProperty(ParameterStorePropertySourceConfigurationProperties.MULTI_REGION_SSM_CLIENT_REGIONS, String[].class)); if (CollectionUtils.isEmpty(regions)) { throw new IllegalArgumentException(String.format("To enable multi region support, the property '%s' must not be empty.", ParameterStorePropertySourceConfigurationProperties.MULTI_REGION_SSM_CLIENT_REGIONS)); } return regions; }
Example 16
Source File: SolrQueryMethod.java From dubbox with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") private <T> List<T> getAnnotationValuesList(Annotation annotation, String attribute, Class<T> clazz) { T[] values = (T[]) AnnotationUtils.getValue(annotation, attribute); return CollectionUtils.arrayToList(values); }
Example 17
Source File: DefaultArangoConverter.java From spring-data with Apache License 2.0 | 4 votes |
private static Collection<?> asCollection(final Object source) { return (source instanceof Collection) ? Collection.class.cast(source) : source.getClass().isArray() ? CollectionUtils.arrayToList(source) : Collections.singleton(source); }
Example 18
Source File: BeanFactoryAwareFunctionRegistryTests.java From spring-cloud-function with Apache License 2.0 | 4 votes |
@Bean public Function<String, List<String>> parseToList() { return v -> CollectionUtils.arrayToList(v.split(",")); }
Example 19
Source File: MappingVaultConverter.java From spring-vault with Apache License 2.0 | 3 votes |
/** * 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 the collection object. Can be a {@link Collection}, array or * singleton object. * @return the {@code source} as {@link Collection}. */ private static Collection<?> asCollection(Object source) { if (source instanceof Collection) { return (Collection<?>) source; } return source.getClass().isArray() ? CollectionUtils.arrayToList(source) : Collections.singleton(source); }