mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-24 18:04:54 +08:00
fix code
This commit is contained in:
parent
0964bb06fc
commit
8e61da83b9
@ -1057,23 +1057,24 @@ public class CollUtil {
|
|||||||
* 2、修改元素对象,返回集合中为修改后的对象
|
* 2、修改元素对象,返回集合中为修改后的对象
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @param <T> 集合元素类型
|
* @param <E> 集合元素类型
|
||||||
* @param collection 集合
|
* @param collection 集合
|
||||||
* @param editor 编辑器接口,{@code null}返回原集合
|
* @param editor 编辑器接口,{@code null}返回原集合
|
||||||
* @return 过滤后的集合
|
* @return 过滤后的集合
|
||||||
*/
|
*/
|
||||||
public static <T> Collection<T> edit(final Collection<T> collection, final UnaryOperator<T> editor) {
|
@SuppressWarnings("unchecked")
|
||||||
|
public static <T extends Collection<E>, E> T edit(final T collection, final UnaryOperator<E> editor) {
|
||||||
if (null == collection || null == editor) {
|
if (null == collection || null == editor) {
|
||||||
return collection;
|
return collection;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Collection<T> collection2 = create(collection.getClass());
|
final T collection2 = (T) create(collection.getClass());
|
||||||
if (isEmpty(collection)) {
|
if (isEmpty(collection)) {
|
||||||
return collection2;
|
return collection2;
|
||||||
}
|
}
|
||||||
|
|
||||||
T modified;
|
E modified;
|
||||||
for (final T t : collection) {
|
for (final E t : collection) {
|
||||||
modified = editor.apply(t);
|
modified = editor.apply(t);
|
||||||
if (null != modified) {
|
if (null != modified) {
|
||||||
collection2.add(modified);
|
collection2.add(modified);
|
||||||
@ -1090,13 +1091,13 @@ public class CollUtil {
|
|||||||
* 1、过滤出需要的对象,{@link Predicate#test(Object)}方法返回true的对象将被加入结果集合中
|
* 1、过滤出需要的对象,{@link Predicate#test(Object)}方法返回true的对象将被加入结果集合中
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @param <T> 集合元素类型
|
* @param <E> 集合元素类型
|
||||||
* @param collection 集合
|
* @param collection 集合
|
||||||
* @param predicate 过滤器,{@code null}返回原集合
|
* @param predicate 过滤器,{@code null}返回原集合
|
||||||
* @return 过滤后的数组
|
* @return 过滤后的数组
|
||||||
* @since 6.0.0
|
* @since 6.0.0
|
||||||
*/
|
*/
|
||||||
public static <T> Collection<T> filter(final Collection<T> collection, final Predicate<T> predicate) {
|
public static <T extends Collection<E>, E> T filter(final T collection, final Predicate<E> predicate) {
|
||||||
if (null == collection || null == predicate) {
|
if (null == collection || null == predicate) {
|
||||||
return collection;
|
return collection;
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ import java.util.Map;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Aviator引擎封装<br>
|
* Aviator引擎封装<br>
|
||||||
* 见:https://github.com/killme2008/aviatorscript
|
* 见:<a href="https://github.com/killme2008/aviatorscript">https://github.com/killme2008/aviatorscript</a>
|
||||||
*
|
*
|
||||||
* @author looly
|
* @author looly
|
||||||
* @since 5.5.0
|
* @since 5.5.0
|
||||||
|
@ -4,7 +4,6 @@ import cn.hutool.core.bean.BeanUtil;
|
|||||||
import cn.hutool.core.bean.copier.CopyOptions;
|
import cn.hutool.core.bean.copier.CopyOptions;
|
||||||
import cn.hutool.core.bean.copier.ValueProvider;
|
import cn.hutool.core.bean.copier.ValueProvider;
|
||||||
import cn.hutool.core.collection.iter.ArrayIter;
|
import cn.hutool.core.collection.iter.ArrayIter;
|
||||||
import cn.hutool.core.collection.iter.IterUtil;
|
|
||||||
import cn.hutool.core.exceptions.UtilException;
|
import cn.hutool.core.exceptions.UtilException;
|
||||||
import cn.hutool.core.io.FileUtil;
|
import cn.hutool.core.io.FileUtil;
|
||||||
import cn.hutool.core.io.IORuntimeException;
|
import cn.hutool.core.io.IORuntimeException;
|
||||||
@ -20,6 +19,7 @@ import cn.hutool.core.text.StrUtil;
|
|||||||
import cn.hutool.core.util.ArrayUtil;
|
import cn.hutool.core.util.ArrayUtil;
|
||||||
import cn.hutool.core.util.CharsetUtil;
|
import cn.hutool.core.util.CharsetUtil;
|
||||||
import cn.hutool.core.util.ObjUtil;
|
import cn.hutool.core.util.ObjUtil;
|
||||||
|
|
||||||
import jakarta.servlet.ServletOutputStream;
|
import jakarta.servlet.ServletOutputStream;
|
||||||
import jakarta.servlet.ServletRequest;
|
import jakarta.servlet.ServletRequest;
|
||||||
import jakarta.servlet.http.Cookie;
|
import jakarta.servlet.http.Cookie;
|
||||||
@ -39,6 +39,7 @@ import java.util.Collections;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -429,9 +430,9 @@ public class JakartaServletUtil {
|
|||||||
return MapUtil.empty();
|
return MapUtil.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
return IterUtil.toMap(
|
return MapUtil.putAll(
|
||||||
new ArrayIter<>(httpServletRequest.getCookies()),
|
|
||||||
new CaseInsensitiveMap<>(),
|
new CaseInsensitiveMap<>(),
|
||||||
|
(Iterator<Cookie>) new ArrayIter<>(httpServletRequest.getCookies()),
|
||||||
Cookie::getName);
|
Cookie::getName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,6 @@ import cn.hutool.core.bean.BeanUtil;
|
|||||||
import cn.hutool.core.bean.copier.CopyOptions;
|
import cn.hutool.core.bean.copier.CopyOptions;
|
||||||
import cn.hutool.core.bean.copier.ValueProvider;
|
import cn.hutool.core.bean.copier.ValueProvider;
|
||||||
import cn.hutool.core.collection.iter.ArrayIter;
|
import cn.hutool.core.collection.iter.ArrayIter;
|
||||||
import cn.hutool.core.collection.iter.IterUtil;
|
|
||||||
import cn.hutool.core.exceptions.UtilException;
|
import cn.hutool.core.exceptions.UtilException;
|
||||||
import cn.hutool.core.io.FileUtil;
|
import cn.hutool.core.io.FileUtil;
|
||||||
import cn.hutool.core.io.IORuntimeException;
|
import cn.hutool.core.io.IORuntimeException;
|
||||||
@ -39,6 +38,7 @@ import java.util.Collections;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -429,9 +429,9 @@ public class ServletUtil {
|
|||||||
return MapUtil.empty();
|
return MapUtil.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
return IterUtil.toMap(
|
return MapUtil.putAll(
|
||||||
new ArrayIter<>(httpServletRequest.getCookies()),
|
|
||||||
new CaseInsensitiveMap<>(),
|
new CaseInsensitiveMap<>(),
|
||||||
|
(Iterator<Cookie>) new ArrayIter<>(httpServletRequest.getCookies()),
|
||||||
Cookie::getName);
|
Cookie::getName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
package cn.hutool.http.server;
|
package cn.hutool.http.server;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
|
||||||
import cn.hutool.core.io.IORuntimeException;
|
import cn.hutool.core.io.IORuntimeException;
|
||||||
import cn.hutool.core.io.IoUtil;
|
import cn.hutool.core.io.IoUtil;
|
||||||
import cn.hutool.core.map.CaseInsensitiveMap;
|
import cn.hutool.core.map.CaseInsensitiveMap;
|
||||||
|
import cn.hutool.core.map.MapUtil;
|
||||||
import cn.hutool.core.map.multi.ListValueMap;
|
import cn.hutool.core.map.multi.ListValueMap;
|
||||||
import cn.hutool.core.net.NetUtil;
|
import cn.hutool.core.net.NetUtil;
|
||||||
import cn.hutool.core.net.multipart.MultipartFormData;
|
import cn.hutool.core.net.multipart.MultipartFormData;
|
||||||
import cn.hutool.core.net.multipart.UploadSetting;
|
import cn.hutool.core.net.multipart.UploadSetting;
|
||||||
|
import cn.hutool.core.text.StrUtil;
|
||||||
import cn.hutool.core.util.ArrayUtil;
|
import cn.hutool.core.util.ArrayUtil;
|
||||||
import cn.hutool.core.util.CharsetUtil;
|
import cn.hutool.core.util.CharsetUtil;
|
||||||
import cn.hutool.core.text.StrUtil;
|
|
||||||
import cn.hutool.http.Header;
|
import cn.hutool.http.Header;
|
||||||
import cn.hutool.http.HttpUtil;
|
import cn.hutool.http.HttpUtil;
|
||||||
import cn.hutool.http.Method;
|
import cn.hutool.http.Method;
|
||||||
@ -25,7 +25,6 @@ import java.net.HttpCookie;
|
|||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -221,9 +220,9 @@ public class HttpServerRequest extends HttpServerBase {
|
|||||||
*/
|
*/
|
||||||
public Map<String, HttpCookie> getCookieMap() {
|
public Map<String, HttpCookie> getCookieMap() {
|
||||||
if (null == this.cookieCache) {
|
if (null == this.cookieCache) {
|
||||||
cookieCache = Collections.unmodifiableMap(CollUtil.toMap(
|
cookieCache = MapUtil.unmodifiable(MapUtil.putAll(
|
||||||
NetUtil.parseCookies(getCookiesStr()),
|
|
||||||
new CaseInsensitiveMap<>(),
|
new CaseInsensitiveMap<>(),
|
||||||
|
NetUtil.parseCookies(getCookiesStr()),
|
||||||
HttpCookie::getName));
|
HttpCookie::getName));
|
||||||
}
|
}
|
||||||
return cookieCache;
|
return cookieCache;
|
||||||
|
@ -58,6 +58,7 @@ public class NullCell implements Cell {
|
|||||||
return this.row;
|
return this.row;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public void setCellType(final CellType cellType) {
|
public void setCellType(final CellType cellType) {
|
||||||
throw new UnsupportedOperationException("Can not set any thing to null cell!");
|
throw new UnsupportedOperationException("Can not set any thing to null cell!");
|
||||||
}
|
}
|
||||||
@ -72,6 +73,7 @@ public class NullCell implements Cell {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public CellType getCellTypeEnum() {
|
public CellType getCellTypeEnum() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -81,6 +83,7 @@ public class NullCell implements Cell {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public CellType getCachedFormulaResultTypeEnum() {
|
public CellType getCachedFormulaResultTypeEnum() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user