org.springside.modules.utils.Collections3 Java Examples
The following examples show how to use
org.springside.modules.utils.Collections3.
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: Servlets.java From spring-boot-quickstart with Apache License 2.0 | 6 votes |
/** * 组合Parameters生成Query String的Parameter部分, 并在paramter name上加上prefix. * * @see #getParametersStartingWith */ public static String encodeParameterStringWithPrefix(Map<String, Object> params, String prefix) { if (Collections3.isEmpty(params)) { return ""; } if (prefix == null) { prefix = ""; } StringBuilder queryStringBuilder = new StringBuilder(); Iterator<Entry<String, Object>> it = params.entrySet().iterator(); while (it.hasNext()) { Entry<String, Object> entry = it.next(); queryStringBuilder.append(prefix).append(entry.getKey()).append('=').append(entry.getValue()); if (it.hasNext()) { queryStringBuilder.append('&'); } } return queryStringBuilder.toString(); }
Example #2
Source File: Servlets.java From dubai with MIT License | 6 votes |
/** * 组合Parameters生成Query String的Parameter部分, 并在paramter name上加上prefix. * * @see #getParametersStartingWith */ public static String encodeParameterStringWithPrefix(Map<String, Object> params, String prefix) { if (Collections3.isEmpty(params)) { return ""; } if (prefix == null) { prefix = ""; } StringBuilder queryStringBuilder = new StringBuilder(); Iterator<Entry<String, Object>> it = params.entrySet().iterator(); while (it.hasNext()) { Entry<String, Object> entry = it.next(); queryStringBuilder.append(prefix).append(entry.getKey()).append('=').append(entry.getValue()); if (it.hasNext()) { queryStringBuilder.append('&'); } } return queryStringBuilder.toString(); }
Example #3
Source File: DynamicSpecifications.java From spring-boot-quickstart with Apache License 2.0 | 4 votes |
public static <T> Specification<T> bySearchFilter(final Collection<SearchFilter> filters, final Class<T> entityClazz) { return new Specification<T>() { @Override public Predicate toPredicate(Root<T> root, CriteriaQuery<?> query, CriteriaBuilder builder) { if (Collections3.isNotEmpty(filters)) { List<Predicate> predicates = Lists.newArrayList(); for (SearchFilter filter : filters) { // nested path translate, 如Task的名为"user.name"的filedName, 转换为Task.user.name属性 String[] names = StringUtils.split(filter.fieldName, "."); Path expression = root.get(names[0]); for (int i = 1; i < names.length; i++) { expression = expression.get(names[i]); } // logic operator switch (filter.operator) { case EQ: predicates.add(builder.equal(expression, filter.value)); break; case LIKE: predicates.add(builder.like(expression, "%" + filter.value + "%")); break; case GT: predicates.add(builder.greaterThan(expression, (Comparable) filter.value)); break; case LT: predicates.add(builder.lessThan(expression, (Comparable) filter.value)); break; case GTE: predicates.add(builder.greaterThanOrEqualTo(expression, (Comparable) filter.value)); break; case LTE: predicates.add(builder.lessThanOrEqualTo(expression, (Comparable) filter.value)); break; } } // 将所有条件用 and 联合起来 if (!predicates.isEmpty()) { return builder.and(predicates.toArray(new Predicate[predicates.size()])); } } return builder.conjunction(); } }; }
Example #4
Source File: User.java From Mario with Apache License 2.0 | 4 votes |
@JsonIgnore public String getRoleNames() { return Collections3.extractToString(roleList, "name", ", "); }
Example #5
Source File: Role.java From Mario with Apache License 2.0 | 4 votes |
@JsonIgnore public String getMenuIds(){ return Collections3.extractToString(menuList, "id", ", "); }
Example #6
Source File: DynamicSpecifications.java From dubai with MIT License | 4 votes |
public static <T> Specification<T> bySearchFilter(final Collection<SearchFilter> filters, final Class<T> entityClazz) { return new Specification<T>() { @Override public Predicate toPredicate(Root<T> root, CriteriaQuery<?> query, CriteriaBuilder builder) { if (Collections3.isNotEmpty(filters)) { List<Predicate> predicates = Lists.newArrayList(); for (SearchFilter filter : filters) { // nested path translate, 如Task的名为"user.name"的filedName, 转换为Task.user.name属性 String[] names = StringUtils.split(filter.fieldName, "."); Path expression = root.get(names[0]); for (int i = 1; i < names.length; i++) { expression = expression.get(names[i]); } // logic operator switch (filter.operator) { case EQ: predicates.add(builder.equal(expression, filter.value)); break; case LIKE: predicates.add(builder.like(expression, "%" + filter.value + "%")); break; case GT: predicates.add(builder.greaterThan(expression, (Comparable) filter.value)); break; case LT: predicates.add(builder.lessThan(expression, (Comparable) filter.value)); break; case GTE: predicates.add(builder.greaterThanOrEqualTo(expression, (Comparable) filter.value)); break; case LTE: predicates.add(builder.lessThanOrEqualTo(expression, (Comparable) filter.value)); break; } } // 将所有条件用 and 联合起来 if (!predicates.isEmpty()) { return builder.and(predicates.toArray(new Predicate[predicates.size()])); } } return builder.conjunction(); } }; }