static Container con0lazy;
@BeforeClass
public static void init() throws Exception
{
final Container parent = new Factory()
{
{
bind(ParentNew.class);
bind(ParentSingle.class);
bind(ParentSet.class);
}
@Override
protected Object forBind(Class<?> c, Bind b) throws Exception
{
return c == X.class ? b.cla(ParentSingle.class) : null;
}
}.create(null);
Factory f = new Factory()
{
{
bind(Object.class);
bind(New2.class);
bind(Single2.class);
bind(Set.class);
bind(ChildSingle.class);
bind(ParentSingle.class);
}
@Override
protected Object forBind(Class<?> c, Bind b) throws Exception
{
return c == Object.class ? b.obj(parent) : b.box == Long.class ? b.obj(9L)
: b.mode(parent.bound(c) ? Inject.Parent.class : b.mode);
}
@Override
protected Object forBind(Class<?> cc, AccessibleObject fp, Class<?> c,
Type generic, Bind b) throws Exception
{
if (c == int.class)
return b.obj( -1);
if (b.box == Long.class)
return null;
if (c == String.class && fp.isAnnotationPresent(Deprecated.class))
return b.obj(Deprecated.class.getName());
if (c == int[].class)
return b.obj(null);
if (cc == Single2.class)
if (c == Single.class)
return b.cla(Single2.class);
else if (((Member)fp).getName().equals("n"))
return b.cla(New2.class);
return null;
}
};
con0 = f.create(parent);
con0lazy = f.create(parent, true);
}