@Override public <T> T newTransient( final Class<T> mixinType, Object... uses ) throws NoSuchTransientTypeException, ConstructionException { return newTransientBuilder( mixinType ).use( uses ).newInstance(); }
public View1 createView1( FooModel model ) { TransientBuilder<View1> builder = transientBuilderFactory.newTransientBuilder( View1.class ); builder.use( model ); return builder.newInstance(); } // END SNIPPET: create
public View2 createView2( FooModel model ) { TransientBuilder<View2> builder = transientBuilderFactory.newTransientBuilder( View2.class ); builder.use( model ); return builder.newInstance(); } }
@Test public void givenMixinUsesGenericListWhenUseListThenInjectWorks() { TransientBuilder<TestCase> builder = transientBuilderFactory.newTransientBuilder( TestCase.class ); ArrayList<String> list = new ArrayList<String>(); list.add( "Hello" ); list.add( "Bye" ); builder.use( list ); TestCase TestCase = builder.newInstance(); TestCase.sayHello(); }
@Test public void givenMixinUsesGenericClassWhenUseClassThenInjectWorks() { TransientBuilder<TestCase> builder = transientBuilderFactory.newTransientBuilder( TestCase.class ); builder.use( UsesGenericClassTest.class ); TestCase testCase = builder.newInstance(); assertThat( "class name is returned", testCase.test(), equalTo( UsesGenericClassTest.class.getName() ) ); }
@Override public AlarmProxy create( Identity identity, String systemName, String categoryName, AlarmClass alarmClass ) { UnitOfWork unitOfWork = uowf.currentUnitOfWork(); AlarmPoint alarmPoint; try { alarmPoint = unitOfWork.get( AlarmPoint.class, identity ); } catch( NoSuchEntityException e ) { alarmPoint = factory.create( identity, systemName, categoryName, alarmClass ); } TransientBuilder<AlarmProxy> builder = tbf.newTransientBuilder( AlarmProxy.class ); builder.prototype().identity().set(identity); builder.prototype().category().set( alarmPoint.category().get() ); builder.prototype().alarmClass().set( alarmClass ); builder.use( identity ); return builder.newInstance(); } }