Skip to content

Instantly share code, notes, and snippets.

@yutax77
yutax77 / Person.java
Created May 29, 2011 01:02
How to deserialize generics class
import flexjson.JSONDeserializer;
public class Person<T extends Detail> {
private String name;
private int age;
private T detail;
public String getName() {
return name;
}
@yutax77
yutax77 / Human.java
Created June 13, 2011 13:52
Collectionメンバー変数もJSON含めてシリアライズする
import java.util.List;
import flexjson.JSONSerializer;
public class Human {
private String name;
private List<String> hobbies; //このフィールドをJSONに含めたい
public String getName() {
return name;
}
@yutax77
yutax77 / gist:2948389
Created June 18, 2012 13:31
How to FORCE update logback's configure file
public void updateConfigure() throws JoranException {
LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
ContextInitializer ci = new ContextInitializer(loggerContext);
JoranConfigurator configurator = new JoranConfigurator();
configurator.setContext(loggerContext);
loggerContext.reset();
configurator.doConfigure(ci.findURLOfDefaultConfigurationFile(false));
}
@yutax77
yutax77 / Hoge.java
Created June 24, 2012 01:30
The class which has Enum variable.
import flexjson.JSONDeserializer;
import flexjson.JSONSerializer;
public class Hoge {
private Color color;
public Hoge(){}
public Color getColor() {
return color;
@yutax77
yutax77 / Circle.java
Created June 25, 2012 11:26
Example Flexjson's TypeLocator.
public class Circle implements Figure {
private Type type;
private int radius;
public Circle(){
type = Type.CIRCLE;
}
public Type getType() {
return type;
@yutax77
yutax77 / file0.java
Last active November 11, 2015 16:49
Initialize the list or array using Stream(Java8) ref: http://qiita.com/yutax77/items/ea1412cc0522435ef101
List<String> list = Stream.generate(() -> "hoge").limit(10).collect(Collectors.toList());