public Expression boxAsSoyValueProvider() {
    if (soyType().equals(NullType.getInstance())) {
      if (delegate == NULL || delegate == NULL_BOXED) {
        return FieldRef.NULL_PROVIDER.accessor();
      }
      // otherwise this expression might have side effects,  evaluate it as a statement then return
      // the NULL_PROVIDER
      return toStatement().then(FieldRef.NULL_PROVIDER.accessor());
    }
    if (delegate.isNonNullable()) {
      // Every SoyValue is-a SoyValueProvider, so if it is non-null
      return box();
    }
    if (isBoxed()) {
      return new Expression(
          BytecodeUtils.SOY_VALUE_PROVIDER_TYPE, delegate.features().plus(Feature.NON_NULLABLE)) {
        @Override
        protected void doGen(CodeBuilder adapter) {
          Label end = new Label();
          delegate.gen(adapter);
          adapter.dup();
          adapter.ifNonNull(end);
          adapter.pop();
          FieldRef.NULL_PROVIDER.accessStaticUnchecked(adapter);
          adapter.mark(end);
        }
      };
    }
    return new Expression(
        BytecodeUtils.SOY_VALUE_PROVIDER_TYPE, delegate.features().plus(Feature.NON_NULLABLE)) {
      @Override
      protected void doGen(CodeBuilder adapter) {
        Label end = new Label();
        delegate.gen(adapter);
        adapter.dup();
        Label nonNull = new Label();
        adapter.ifNonNull(nonNull);
        adapter.pop(); // pop the null value and replace with the nullprovider
        FieldRef.NULL_PROVIDER.accessStaticUnchecked(adapter);
        adapter.goTo(end);
        adapter.mark(nonNull);
        doBox(adapter, soyRuntimeType);
        adapter.mark(end);
      }
    };
  }
public Expression boxAsSoyValueProvider ( ) { if ( soyType ( ) . equals ( NullType . getInstance ( ) ) ) { if ( delegate == NULL || delegate == NULL_BOXED ) { return FieldRef . NULL_PROVIDER . accessor ( ) ; } return toStatement ( ) . then ( FieldRef . NULL_PROVIDER . accessor ( ) ) ; } if ( delegate . isNonNullable ( ) ) { return box ( ) ; } if ( isBoxed ( ) ) { return new Expression ( BytecodeUtils . SOY_VALUE_PROVIDER_TYPE , delegate . features ( ) . plus ( Feature . NON_NULLABLE ) ) { @ Override protected void doGen ( CodeBuilder adapter ) { Label end = new Label ( ) ; delegate . gen ( adapter ) ; adapter . dup ( ) ; adapter . ifNonNull ( end ) ; adapter . pop ( ) ; FieldRef . NULL_PROVIDER . accessStaticUnchecked ( adapter ) ; adapter . mark ( end ) ; } } ; } return new Expression ( BytecodeUtils . SOY_VALUE_PROVIDER_TYPE , delegate . features ( ) . plus ( Feature . NON_NULLABLE ) ) { @ Override protected void doGen ( CodeBuilder adapter ) { Label end = new Label ( ) ; delegate . gen ( adapter ) ; adapter . dup ( ) ; Label nonNull = new Label ( ) ; adapter . ifNonNull ( nonNull ) ; adapter . pop ( ) ; FieldRef . NULL_PROVIDER . accessStaticUnchecked ( adapter ) ; adapter . goTo ( end ) ; adapter . mark ( nonNull ) ; doBox ( adapter , soyRuntimeType ) ; adapter . mark ( end ) ; } } ; }
Returns an Expression of a non-null {@link SoyValueProvider} providing this value.