Java Code Examples for org.osgl.inject.Genie#create()
The following examples show how to use
org.osgl.inject.Genie#create() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GH54.java From java-di with Apache License 2.0 | 6 votes |
@Test public void test() { Genie genie = Genie.create(new Module() { @Override protected void configure() { bind(TypedElementLoader.class).to(new TypedElementLoader() { @Override protected List<Class> load(Class type, boolean loadNonPublic, boolean loadAbstract, boolean loadRoot) { List<Class> list = new ArrayList<>(); list.add(Color.class); return list; } }); } }); GH54 gh54 = genie.get(GH54.class); eq(Color.DarkBlue, gh54.colors.get(Keyword.of("dark-blue"))); }
Example 2
Source File: GH55.java From java-di with Apache License 2.0 | 6 votes |
@Test public void test() { Genie genie = Genie.create(new Module() { @Override protected void configure() { bind(TypedElementLoader.class).to(new TypedElementLoader() { @Override protected List<Class> load(Class type, boolean loadNonPublic, boolean loadAbstract, boolean loadRoot) { List<Class> list = new ArrayList<>(); list.add(Size.class); return list; } }); } }); GH55 gh55 = genie.get(GH55.class); eq(3, gh55.sizes.size()); }
Example 3
Source File: GH56.java From java-di with Apache License 2.0 | 6 votes |
@Test public void test() { Genie genie = Genie.create(new Module() { @Override protected void configure() { bind(TypedElementLoader.class).to(new TypedElementLoader() { @Override protected List<Class> load(Class type, boolean loadNonPublic, boolean loadAbstract, boolean loadRoot) { List<Class> list = new ArrayList<>(); list.add(Color.class); return list; } }); } }); GH56 gh56 = genie.get(GH56.class); eq(3, gh56.colorList.size()); eq(Color.B, gh56.colorLookup.get("B")); }
Example 4
Source File: GH57.java From java-di with Apache License 2.0 | 5 votes |
@Test public void test() { Genie genie = Genie.create(); BeanSpec spec = BeanSpec.of(TestResp.class, genie); Map<String, BeanSpec> fieldSpecs = spec.fields(); eq(Object.class, fieldSpecs.get("result").rawType()); eq(Integer.class, fieldSpecs.get("code").rawType()); }
Example 5
Source File: Gh18.java From java-di with Apache License 2.0 | 5 votes |
@Test @Ignore public void test() { Genie genie = Genie.create(); BeanSpec spec = BeanSpec.of(int[].class, genie); eq(int.class, spec.typeParams().get(0)); }
Example 6
Source File: GH38.java From java-di with Apache License 2.0 | 5 votes |
@Test public void test() { Genie genie = Genie.create(); LinkedHashMap<String, Integer> map = genie.get(LinkedHashMap.class); notNull(map); yes(map.isEmpty()); }
Example 7
Source File: GH25.java From java-di with Apache License 2.0 | 5 votes |
@Test public void test() { Genie genie = Genie.create(); genie.registerNamedProvider(Foo.class, new FooProvider()); FooHolder fooHolder = genie.get(FooHolder.class); eq("bar", fooHolder.foo.name); }
Example 8
Source File: Gh19.java From java-di with Apache License 2.0 | 5 votes |
@Test public void test() { Genie genie = Genie.create(); BeanSpec spec = BeanSpec.of(IntA.class, genie); yes(spec.isInterface()); spec = BeanSpec.of(Gh19.class, genie); no(spec.isInterface()); }
Example 9
Source File: GH26.java From java-di with Apache License 2.0 | 5 votes |
@Test public void test() { Genie genie = Genie.create(); BeanSpec fooHolderSpec = BeanSpec.of(FooHolder.class, genie); BeanSpec fooSpec = fooHolderSpec.field("foo"); BeanSpec dataSpec = fooSpec.field("data"); eq(String.class, dataSpec.rawType()); }
Example 10
Source File: GH47.java From java-di with Apache License 2.0 | 5 votes |
@Test public void test() { Genie genie = Genie.create(); BeanSpec spec = BeanSpec.of(Foo.class, genie); List<BeanSpec> fields = spec.nonStaticFields(); spec = fields.get(0); fields = spec.nonStaticFields(); eq(9, fields.size()); }
Example 11
Source File: GH33.java From java-di with Apache License 2.0 | 5 votes |
@Test public void test() { Genie genie = Genie.create(); BeanSpec spec = BeanSpec.of(ItemMapper.class, genie); BeanSpec parent = spec.parent(); List<Type> typeParams = parent.typeParams(); eq(1, typeParams.size()); eq(PackItem.class, typeParams.get(0)); }
Example 12
Source File: GH45.java From java-di with Apache License 2.0 | 5 votes |
@Test public void test() { Genie genie = Genie.create(); Field field = $.fieldOf(Foo.class, "list"); Type type = field.getGenericType(); Map<String, Class> typeLookup = C.Map("ID", Long.class); BeanSpec spec = BeanSpec.of(type, genie, typeLookup); List<Type> typeParams = spec.typeParams(); eq(Long.class, typeParams.get(0)); }
Example 13
Source File: GH43.java From java-di with Apache License 2.0 | 5 votes |
@Test public void test() { Genie genie = Genie.create(); Method method = $.getMethod(Foo.class, "doIt", List.class); Map<String, Class> typeVarLookup = Generics.buildTypeParamImplLookup(IntFoo.class); Type type = method.getGenericParameterTypes()[0]; Annotation[] anno = method.getParameterAnnotations()[0]; BeanSpec spec = BeanSpec.of(type, anno, genie, typeVarLookup); }
Example 14
Source File: Gh58.java From java-di with Apache License 2.0 | 5 votes |
@Test public void test() { Genie genie = Genie.create(); Integer i = genie.get(Integer.class); BeanSpec fooSpec = BeanSpec.of(Foo.class, genie); no(genie.subjectToInject(fooSpec)); genie.get(Foo.class); no(genie.subjectToInject(fooSpec)); }
Example 15
Source File: GH181.java From java-tool with Apache License 2.0 | 4 votes |
@Test public void test() { Genie genie = Genie.create(); Order.Dao orderDao = genie.get(Order.Dao.class); notNull(orderDao.accDao); }
Example 16
Source File: GH10.java From java-di with Apache License 2.0 | 4 votes |
@Test public void test() { Genie genie = Genie.create(Binder.class); A a = genie.get(A.class); eq("foo", a.a()); }
Example 17
Source File: Act.java From actframework with Apache License 2.0 | 4 votes |
private static Genie genie() { if (null == genie) { genie = Genie.create(); } return genie; }
Example 18
Source File: Gh20.java From java-di with Apache License 2.0 | 4 votes |
@Test public void test() { Genie genie = Genie.create(); BeanSpec spec = BeanSpec.of(int[].class, genie); eq(int.class, spec.componentSpec().rawType()); }
Example 19
Source File: GH42.java From java-di with Apache License 2.0 | 4 votes |
@Test public void test() { Genie genie = Genie.create(); Order.Dao orderDao = genie.get(Order.Dao.class); notNull(orderDao.accDao); }
Example 20
Source File: Gh59.java From java-di with Apache License 2.0 | 4 votes |
@Test public void test() { Genie genie = Genie.create(); eq(0, genie.get(Integer.class)); }