12345678910111213141516171819202122232425262728293031323334353637 |
- package com.gyee.wisdom.adapter.common.util;
- import com.gyee.wisdom.adapter.model.adapter.ToData;
- import java.util.Collection;
- import java.util.List;
- import java.util.Optional;
- import java.util.stream.Collectors;
- public abstract class DataUtil {
- private DataUtil() {
- }
- public static <T> List<T> convertDataList(Collection<? extends ToData<T>> toDataList) {
- return toDataList.stream().map(ToData::toData).collect(Collectors.toList());
- }
- public static <T> T getData(ToData<T> data) {
- return Optional.ofNullable(data).isPresent() ? data.toData() : null;
- }
- public static String convertStringToSql(String ...content){
- if (content == null)
- return null;
- StringBuilder sb = new StringBuilder();
- for (String data : content){
- sb.append("'").append(data).append("',");
- }
- String sql = sb.toString();
- return sql.substring(0, sql.length() - 1);
- }
- }
|