@Override
    public Optional<B> transform(Generator gen, A model) {
        requireNonNull(gen);
        requireNonNull(model);
        
        Object o = model;
        
        for (final Transform<?, ?> step : steps) {
            if (o == null) {
                return Optional.empty();
            } else {
                @SuppressWarnings("unchecked")
                final Transform<Object, ?> step2 = (Transform<Object, ?>) step;
                
                o = gen.transform(step2, o, factory)
                    .map(Meta::getResult)
                    .orElse(null);
            }
        }
        
        if (o == null) {
            return Optional.empty();
        } else {
            if (to.isAssignableFrom(o.getClass())) {
                @SuppressWarnings("unchecked")
                final B result = (B) o;
                return Optional.of(result);
            } else {
                throw new IllegalStateException(
                    "The bridge between '" + 
                    from.getSimpleName() + 
                    "' to '" + 
                    to.getSimpleName() + 
                    "' is not complete."
                );
            }
        }
    }
Transforms the specified model using this transform. A code generator is
supplied so that the transform can initiate new generation processes to
resolve dependencies.

@param gen   the current code generator 
@param model the model to transform
@return      the transformation result or empty if any of the steps 
             returned empty
common-parent/codegen/src/main/java/com/speedment/common/codegen/internal/BridgeTransform.java