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
// A Command Pattern example | |
// Oringinal example from https://dzone.com/articles/design-patterns-command and I modify it using java8 | |
public class Client { | |
public static void main(String[] args) { | |
// Receiver | |
Light light = new Light(); | |
// Invoker | |
RemoteControl remoteControl = new RemoteControl(); |
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 interview; | |
import com.alibaba.fastjson.JSON; | |
import lombok.Data; | |
import java.nio.file.Path; | |
import java.nio.file.Paths; | |
import java.util.*; | |
import static java.util.Comparator.comparing; |
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
import org.junit.Before; | |
import org.junit.Test; | |
import sun.misc.Unsafe; | |
import sun.reflect.ReflectionFactory; | |
import java.lang.reflect.Constructor; | |
import java.lang.reflect.Field; | |
import java.lang.reflect.Modifier; | |
import static org.junit.Assert.assertEquals; |
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 interview; | |
import java.util.Map; | |
import java.util.Random; | |
import java.util.concurrent.ConcurrentHashMap; | |
import static java.util.Optional.ofNullable; | |
/** | |
* <pre> |
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
Map<String,String> areaCode2AddrMap = new HashMap<>(); | |
for(AreaCode areaCode:areaCodeList){ | |
if(areaCode2AddrMap.get(areaCode.getCode())!=null){ | |
String value = areaCode2AddrMap.get(areaCode.getCode())+","+areaCode.getAddr(); | |
areaCode2AddrMap.put(areaCode.getCode(),value); | |
}else{ | |
areaCode2AddrMap.put(areaCode.getCode(),areaCode.getAddr()); | |
} | |
} | |
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 String loadPemKey(String fileName) throws Exception { | |
// TODO: 可以考虑用Java8重写 | |
BufferedReader br = new BufferedReader(new FileReader(PATH + fileName)); | |
String s = br.readLine(); | |
String str = ""; | |
s = br.readLine(); | |
while (s.charAt(0) != '-') { | |
//str += s + "\r"; | |
str+=s; | |
s = br.readLine(); |
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
import org.junit.Test; | |
import java.util.ArrayList; | |
import java.util.List; | |
import static org.junit.Assert.assertEquals; | |
import static org.junit.Assert.assertTrue; | |
/** | |
* Created by zhuguowei on 4/12/17. |
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 com.tn.api.service; | |
import com.tn.api.dao.TestDao; | |
import lombok.extern.slf4j.Slf4j; | |
import org.junit.Test; | |
import org.junit.runner.RunWith; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.test.context.ContextConfiguration; | |
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; |
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 com.zhugw.common.util; | |
import com.esotericsoftware.reflectasm.ConstructorAccess; | |
import org.springframework.cglib.beans.BeanCopier; | |
import org.springframework.util.CollectionUtils; | |
import java.util.ArrayList; | |
import java.util.Collections; | |
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 com.helijia.lottery.service; | |
import com.helijia.common.api.model.ApiException; | |
import com.helijia.lottery.dao.mapper.TestMapper; | |
import org.apache.commons.lang.RandomStringUtils; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.jdbc.datasource.DataSourceTransactionManager; | |
import org.springframework.stereotype.Service; | |
import org.springframework.transaction.TransactionDefinition; | |
import org.springframework.transaction.TransactionStatus; |