@SuppressWarnings( "unchecked" ) private <T> T createInstance( ValueBuilder<?> builder ) { return (T) builder.newInstance(); } }
public Links newLinks() { return linksBuilder.newInstance(); } }
public Table newTable() { if (rowBuilder != null) endRow(); return tableBuilder.newInstance(); }
public TableQuery newQuery() { String query = ""; if (select != null) query+= "select "+select.toString(); queryBuilder.prototype().tq().set( query ); return queryBuilder.newInstance(); } }
public TableBuilder endRow() { tableBuilder.prototype().rows().get().add(rowBuilder.newInstance()); rowBuilder = null; return this; }
public T newInstance( Module module ) { ValueBuilder<T> builder = module.newValueBuilder( type ); build( builder.prototype() ); return builder.newInstance(); } }
@Override public RestListValue newListRepresentationValue( Reference listRef, int start, Iterable<RestValue> items ) { ValueBuilder<RestListValue> builder = vbf.newValueBuilder( RestListValue.class ); RestListValue listRepresentation = builder.prototype(); listRepresentation.uri().set( listRef.toString() ); listRepresentation.start().set( start ); for ( RestValue eachItem : items ) { listRepresentation.items().get().add( eachItem ); } return builder.newInstance(); }
private SomeValue newSomeValue( String foo, String cathedral ) { ValueBuilder<SomeValue> builder = module.newValueBuilder( SomeValue.class ); SomeValue value = builder.prototype(); value.foo().set( foo ); if( cathedral != null ) { value.cathedral().set( cathedral ); } return builder.newInstance(); } }
public TableBuilder cell(Object v, String f) { ValueBuilder<Cell> cellBuilder = vbf.newValueBuilder(Cell.class); cellBuilder.prototype().v().set(v); cellBuilder.prototype().f().set(f); rowBuilder.prototype().c().get().add(cellBuilder.newInstance()); return this; }
private AnotherValue createAnotherValue( String val1, String val2 ) { ValueBuilder<AnotherValue> valueBuilder = module.newValueBuilder( AnotherValue.class ); valueBuilder.prototype().val1().set( val1 ); valueBuilder.prototypeFor( AnotherValueInternalState.class ).val2().set( val2 ); return valueBuilder.newInstance(); }
private Schedule newTransientOnceSchedule( Task task, DateTime runAt ) { ValueBuilder<OnceSchedule> builder = module.newValueBuilder( OnceSchedule.class ); OnceSchedule builderInstance = builder.prototype(); builderInstance.task().set( task ); builderInstance.start().set( runAt ); builderInstance.identity().set( uuid.generate( CronSchedule.class ) ); OnceSchedule schedule = builder.newInstance(); logger.info( "Schedule {} created: {}", schedule.presentationString(), schedule.identity().get() ); return schedule; }
private CronSchedule newTransientCronSchedule( Task task, String cronExpression, DateTime start ) { ValueBuilder<CronSchedule> builder = module.newValueBuilder( CronSchedule.class ); CronSchedule prototype = builder.prototype(); prototype.task().set( task ); prototype.start().set( start ); prototype.identity().set( uuid.generate( CronSchedule.class ) ); prototype.cronExpression().set( cronExpression ); CronSchedule schedule = builder.newInstance(); logger.info( "Schedule {} created: {}", schedule.presentationString(), schedule.identity().get() ); return schedule; }
public TableBuilder column(String id, String label, String type) { ValueBuilder<Column> builder = vbf.newValueBuilder(Column.class); builder.prototype().id().set(id); if (tableQuery != null && tableQuery.label() != null) { // TODO Fix label selection } builder.prototype().label().set(label); builder.prototype().columnType().set(type); tableBuilder.prototype().cols().get().add(builder.newInstance()); return this; }
@Test public void script08() { ValueBuilder<QueryParam> queryParamBuilder = this.module.newValueBuilder( QueryParam.class ); QueryParam param = queryParamBuilder.prototype(); param.name().set( "user" ); param.value().set( "jackdoe" ); QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class ); Property<Collection<QueryParam>> paramsProp = templateFor( Person.class ).personalWebsite().get().queryParams(); qb = qb.where( contains( paramsProp, queryParamBuilder.newInstance() ) ); Query<Person> query = unitOfWork.newQuery( qb ); System.out.println( "*** script08: " + query ); verifyUnorderedResults( query, JACK ); }
@Test public void script09() { ValueBuilder<QueryParam> queryParamBuilder = this.module.newValueBuilder( QueryParam.class ); QueryParam param = queryParamBuilder.prototype(); param.name().set( "user" ); param.value().set( "jackdoe" ); QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class ); Property<Collection<QueryParam>> paramsProp = templateFor( Person.class ).personalWebsite().get().queryParams(); qb = qb.where( not( contains( paramsProp, queryParamBuilder.newInstance() ) ) ); Query<Person> query = unitOfWork.newQuery( qb ); System.out.println( "*** script09: " + query ); verifyUnorderedResults( query, ANN, JOE ); }
@Test public void script02() { ValueBuilder<Address> addressBuilder = this.module.newValueBuilder( Address.class ); Address address = addressBuilder.prototype(); address.line1().set( "Qi Street 4j" ); address.line2().set( "Off main Java Street" ); address.zipcode().set( "12345" ); QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class ); Property<Address> addressProp = templateFor( Person.class ).address(); qb = qb.where( not( eq( addressProp, addressBuilder.newInstance() ) ) ); Query<Person> query = unitOfWork.newQuery( qb ); System.out.println( "*** script02: " + query ); verifyUnorderedResults( query, JOE, JACK ); }
public T addLink( String description, String id, String rel, String href, String classes ) { linkBuilder.prototype().text().set( description ); linkBuilder.prototype().id().set( id ); linkBuilder.prototype().rel().set( rel ); linkBuilder.prototype().href().set( href ); linkBuilder.prototype().classes().set( classes ); addLink( linkBuilder.newInstance() ); return (T) this; }
@Override public X509ProfileValue x509Profile( X509Profile x509Profile ) { ValueBuilder<X509ProfileValue> x509ProfileValueBuilder = vbf.newValueBuilder( X509ProfileValue.class ); CaUriBuilder caUriBuilder = new CaUriBuilder( restApi.apiRootRef() ); X509ProfileValue x509ProfileValue = x509ProfileValueBuilder.prototype(); x509ProfileValue.uri().set( caUriBuilder.x509Profile().withIdentity( x509Profile.identity().get() ).build() ); x509ProfileValue.name().set( x509Profile.name().get() ); x509ProfileValue.validityDays().set( x509Profile.validityDays().get() ); return x509ProfileValueBuilder.newInstance(); }
@Override public CryptoStoreValue cryptoStore( CryptoStore cs ) { ValueBuilder<CryptoStoreValue> ksValueBuilder = vbf.newValueBuilder( CryptoStoreValue.class ); CaUriBuilder caUriBuilder = new CaUriBuilder( restApi.apiRootRef() ); CryptoStoreValue ksValue = ksValueBuilder.prototype(); ksValue.uri().set( caUriBuilder.cryptoStore().withIdentity( cs.identity().get() ).build() ); ksValue.name().set( cs.name().get() ); ksValue.storeType().set( cs.storeType().get() ); return ksValueBuilder.newInstance(); }
@Override public RevocationValue revocation( Revocation revocation ) { ValueBuilder<RevocationValue> revocationValueBuilder = vbf.newValueBuilder( RevocationValue.class ); CaUriBuilder caUriBuilder = new CaUriBuilder( restApi.apiRootRef() ); RevocationValue revocationValue = revocationValueBuilder.prototype(); revocationValue.x509Uri().set( caUriBuilder.x509().withIdentity( revocation.x509().get().identity().get() ).build() ); revocationValue.uri().set( caUriBuilder.x509().withIdentity( revocation.x509().get().identity().get() ).revocation().build() ); revocationValue.reason().set( revocation.reason().get() ); return revocationValueBuilder.newInstance(); }