@Override public D build() { return builder.build(); } }
/** * Utility method, if a {@link Builder} is undefined (null) then return null * otherwise call {@link Builder#build()} on that builder * * @param <T> Type expected from the builder * @param builder Builder to use, may be null * @return null if builder is null otherwise returns result of {@link Builder#build()} */ public static final <T> T build( @Nullable final Builder<T> builder ) { return builder == null ? null : builder.build(); }
/** * Utility method to build from a Collection of builders and add them to a list * * @param <B> Type of Builder * @param <T> Type of built object * @param builders Collection of builders to invoke * @param list List to add built objects to */ public static final <B extends Builder<T>, T> void buildAll( final Collection<B> builders, final List<T> list ) { for( B builder : builders ) { list.add( builder.build() ); } }
@Override protected ConstantOp createOp() { return new ConstantOp( builder.build() ); } }
@Override protected NumberOp<N> build( @Nonnull final NumberOp<N> op ) { op.setValue( builder.build() ); return super.build( op ); }
/** * Utility method, if a {@link Builder} is undefined (null) then return null * otherwise if it's a {@link LastBuilder} then call * {@link LastBuilder#buildIfNeeded()} on that builder, otherwise just * call {@link Builder#build()} * * @param <T> Type expected from the builder * @param builder Builder to use, may be null * @return null if builder is null otherwise returns result of * {@link LastBuilder#buildIfNeeded()} * @see LastBuilder#buildIfNeeded() */ public static final <T> T buildIfNeeded( @Nullable final Builder<T> builder ) { if( builder == null ) { return null; } else if( builder instanceof LastBuilder ) { return ((LastBuilder<T>) builder).buildIfNeeded(); } else { return builder.build(); } }
/** * {@inheritDoc} */ @Override public final XMPPLogic<A, B> build() { resetLastBuild(); // Adds the default logic if none set if( isEmpty() ) { addDefaultLogic(); } XMPPProtocolLogicSet<A, B> set = new XMPPProtocolLogicSet<A, B>(); for( Builder builder : getContent() ) { set.add( (XMPPLogic<A, B>) builder.build() ); } return setLastBuild( set ); }