use of org.nutz.ioc.ValueProxyMaker in project nutz by nutzam.
the class IocCustomizedValueTypeTest method test_simple_customized.
@Test
public void test_simple_customized() {
String json = "{xb:{name:{cc:'XiaoBai'}}}";
Ioc2 ioc = new NutIoc(new MapLoader(json));
ioc.addValueProxyMaker(new ValueProxyMaker() {
public ValueProxy make(IocMaking ing, IocValue iv) {
if ("cc".equalsIgnoreCase(iv.getType())) {
return new StaticValue("CC:" + iv.getValue());
}
return null;
}
public String[] supportedTypes() {
return Lang.array("cc");
}
});
Pet pet = ioc.get(Pet.class, "xb");
assertEquals("CC:XiaoBai", pet.getName());
ioc.depose();
}
Aggregations