mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-05 17:37:59 +08:00
add methods
This commit is contained in:
parent
8bb73f3829
commit
85eab64171
@ -389,32 +389,6 @@ public class ListUtil {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑列表,此方法会修改原列表的内容<br>
|
||||
* 编辑过程通过传入的Editor实现编辑列表中元素内容,这个Editor实现可以实现以下功能:
|
||||
*
|
||||
* <pre>
|
||||
* 1、修改元素对象,返回集合中为修改后的对象
|
||||
* </pre>
|
||||
*
|
||||
* @param <T> 集合元素类型
|
||||
* @param list 集合
|
||||
* @param editor 编辑器接口
|
||||
* @return 编辑后的数组
|
||||
* @since 4.1.8
|
||||
*/
|
||||
public static <T> List<T> edit(List<T> list, Editor<T> editor) {
|
||||
if (null == list || null == editor) {
|
||||
return list;
|
||||
}
|
||||
|
||||
for (T t : list) {
|
||||
editor.edit(t);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 过滤<br>
|
||||
* 过滤过程通过传入的Editor实现来返回需要的元素内容,这个Editor实现可以实现以下功能:
|
||||
|
@ -0,0 +1,18 @@
|
||||
package cn.hutool.core.collection;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ListUtilTest {
|
||||
|
||||
@Test
|
||||
public void filterTest(){
|
||||
List<String> a = ListUtil.toLinkedList("1", "2", "3");
|
||||
final List<String> filter = ListUtil.filter(a, str -> "edit" + str);
|
||||
Assert.assertEquals("edit1", filter.get(0));
|
||||
Assert.assertEquals("edit2", filter.get(1));
|
||||
Assert.assertEquals("edit3", filter.get(2));
|
||||
}
|
||||
}
|
@ -14,6 +14,7 @@ import org.bouncycastle.jce.spec.ECNamedCurveSpec;
|
||||
import org.bouncycastle.jce.spec.ECParameterSpec;
|
||||
import org.bouncycastle.math.ec.ECCurve;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.math.BigInteger;
|
||||
import java.security.GeneralSecurityException;
|
||||
import java.security.InvalidKeyException;
|
||||
@ -320,6 +321,30 @@ public class BCUtil {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取PEM格式的私钥
|
||||
*
|
||||
* @param pemStream pem流
|
||||
* @return {@link PrivateKey}
|
||||
* @since 5.2.5
|
||||
* @see PemUtil#readPemPrivateKey(InputStream)
|
||||
*/
|
||||
public static PrivateKey readPemPrivateKey(InputStream pemStream) {
|
||||
return PemUtil.readPemPrivateKey(pemStream);
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取PEM格式的公钥
|
||||
*
|
||||
* @param pemStream pem流
|
||||
* @return {@link PublicKey}
|
||||
* @since 5.2.5
|
||||
* @see PemUtil#readPemPublicKey(InputStream)
|
||||
*/
|
||||
public static PublicKey readPemPublicKey(InputStream pemStream) {
|
||||
return PemUtil.readPemPublicKey(pemStream);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将X,Y曲线点编码为bytes
|
||||
*
|
||||
|
@ -37,7 +37,7 @@ public class PemUtil {
|
||||
* @since 4.5.2
|
||||
*/
|
||||
public static PrivateKey readPemPrivateKey(InputStream pemStream) {
|
||||
return (PrivateKey) PemUtil.readPemKey(pemStream);
|
||||
return (PrivateKey) readPemKey(pemStream);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -48,7 +48,7 @@ public class PemUtil {
|
||||
* @since 4.5.2
|
||||
*/
|
||||
public static PublicKey readPemPublicKey(InputStream pemStream) {
|
||||
return (PublicKey) PemUtil.readPemKey(pemStream);
|
||||
return (PublicKey) readPemKey(pemStream);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user