@Test public void normalLeft() { ExpressionResult actual = testSubject.apply(expressionContext, mapValue("value", stringValue("abcdefg"))); assertEquals("ab", actual.getValue()); }
@Override public ExpressionResult apply(ExpressionContext context, ExpressionResult input) { ExpressionResult value = valueExpression.apply(context, input); if( value == null || ! value.isNonNull() ) return NullExpressionResult.INSTANCE; int chars = charsExpression.apply(context, input).getNumericValue().intValue(); String string = value.toString(); if( string.length() < chars) return new StringExpressionResult(string); return new StringExpressionResult(string.substring(0, chars)); }
LeftExpression implements Expression { @Override public ExpressionResult apply(ExpressionContext context, ExpressionResult input) { ExpressionResult value = valueExpression.apply(context, input); if( value == null || ! value.isNonNull() ) return NullExpressionResult.INSTANCE; int chars = charsExpression.apply(context, input).getNumericValue().intValue(); String string = value.toString(); if( string.length() < chars) return new StringExpressionResult(string); return new StringExpressionResult(string.substring(0, chars)); } }
LeftExpression implements Expression { @Override public ExpressionResult apply(ExpressionContext context, ExpressionResult input) { ExpressionResult value = valueExpression.apply(context, input); if( value == null || ! value.isNonNull() ) return NullExpressionResult.INSTANCE; int chars = charsExpression.apply(context, input).getNumericValue().intValue(); String string = value.toString(); if( string.length() < chars) return new StringExpressionResult(string); return new StringExpressionResult(string.substring(0, chars)); } LeftExpression(String alias, Expression[] expressions); }
LeftExpression implements Expression { @Override public ExpressionResult apply(ExpressionContext context, ExpressionResult input) { ExpressionResult value = valueExpression.apply(context, input); if( value == null || ! value.isNonNull() ) return NullExpressionResult.INSTANCE; int chars = charsExpression.apply(context, input).getNumericValue().intValue(); String string = value.toString(); if( string.length() < chars) return new StringExpressionResult(string); return new StringExpressionResult(string.substring(0, chars)); } LeftExpression(String alias, Expression[] expressions); @Override ExpressionResult apply(ExpressionContext context, ExpressionResult input); @Override String alias(); }
LeftExpression implements Expression { @Override public ExpressionResult apply(ExpressionContext context, ExpressionResult input) { ExpressionResult value = valueExpression.apply(context, input); if( value == null || ! value.isNonNull() ) return NullExpressionResult.INSTANCE; int chars = charsExpression.apply(context, input).getNumericValue().intValue(); String string = value.toString(); if( string.length() < chars) return new StringExpressionResult(string); return new StringExpressionResult(string.substring(0, chars)); } LeftExpression(String alias, Expression[] expressions); @Override ExpressionResult apply(ExpressionContext context, ExpressionResult input); @Override String alias();  }