This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void makeSettable(Field f) { | |
try { | |
Field modifiersField = Field.class.getDeclaredField("modifiers"); | |
modifiersField.setAccessible(true); | |
modifiersField.setInt(f, f.getModifiers() & ~Modifier.FINAL); | |
f.setAccessible(true); | |
} catch (Exception e) { | |
throw new RuntimeException(e); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package test; | |
import java.util.ArrayList; | |
import java.util.Iterator; | |
import java.util.LinkedHashSet; | |
import java.util.List; | |
import java.util.Random; | |
import java.util.Set; | |
/** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public final class AlphabetEncoder { | |
private static final String[] ALPHABET = { "0", "1", "2", "3", "4", "5", "6", | |
"7", "8", "9", "成", "都", "欢", "迎", | |
"你", "们" }; | |
private static final long ENCODE_LENGTH = ALPHABET.length; | |
private static final Map<String, Integer> idxMap = new HashMap<>(); | |
static { | |
for (int i = 0; i < ALPHABET.length; i++) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 计算扫描覆盖率的通用算法 | |
* cover_rate递推公式为:fn = (1 - fn-1) * N/M + fn-1 ; 其中fn是本次迭代cover_rate, fn-1是上次迭代cover_rate, N是本次抽取数量,M是集合总数,f0=0; | |
*/ | |
public static BigDecimal scanCoverageRecur(BigDecimal fn1, int N, BigInteger M, int scale) { | |
if (fn1 == null) | |
fn1 = new BigDecimal(0); | |
BigDecimal one = new BigDecimal(1); | |
BigDecimal Nb = new BigDecimal(N); | |
BigDecimal Mb = new BigDecimal(M); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package test; | |
import java.nio.charset.Charset; | |
import org.apache.commons.codec.binary.Base64; | |
import org.springframework.security.crypto.encrypt.BytesEncryptor; | |
import org.springframework.security.crypto.encrypt.Encryptors; | |
/** | |
* 简易的字段隐藏工具,用于选择性地对原值做全部、部分加密/解密; 用于一些页面展示/表单提交的信息展示场景 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- 注意这里需要用 isNotEmpty 保证更新目标的关键字段不能被更新为null,这里的insert仅仅为了实现selectForUpdate的行级锁而做,其中目标字段在数据库中必须为nullable --> | |
<insert id="asa.AsaDdMediaDAO.insertOrUpdate" parameterClass="AsaDdMediaDO"> | |
insert into | |
asa_dd_media(gmt_create, | |
gmt_modified, url, type, media_id) values ( | |
now(), now(), #url#, #type#, #mediaId#) | |
ON | |
DUPLICATE KEY | |
UPDATE gmt_modified = now(), type = #type# | |
<isNotEmpty prepend="," property="mediaId"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package test.common.quartz; | |
import org.quartz.spi.TriggerFiredBundle; | |
import org.springframework.beans.BeansException; | |
import org.springframework.beans.factory.config.AutowireCapableBeanFactory; | |
import org.springframework.context.ApplicationContext; | |
import org.springframework.context.ApplicationContextAware; | |
import org.springframework.scheduling.quartz.SpringBeanJobFactory; | |
/** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package test; | |
import java.beans.BeanInfo; | |
import java.beans.IntrospectionException; | |
import java.beans.Introspector; | |
import java.beans.PropertyDescriptor; | |
import java.lang.reflect.Array; | |
import java.lang.reflect.Constructor; | |
import java.lang.reflect.Method; | |
import java.lang.reflect.Modifier; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package test; | |
import java.lang.reflect.ParameterizedType; | |
import java.lang.reflect.Type; | |
import java.util.ArrayList; | |
import java.util.HashMap; | |
import java.util.List; | |
import java.util.Map; | |
/** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package test; | |
import java.io.IOException; | |
import java.io.UnsupportedEncodingException; | |
import java.net.UnknownHostException; | |
import java.nio.charset.Charset; | |
import java.util.ArrayList; | |
import java.util.Arrays; | |
import java.util.List; | |
import java.util.Map; |
NewerOlder