@Test public void tooShort() { ExpressionResult actual = testSubject.apply(expressionContext, mapValue("value", stringValue("a"))); assertEquals("a", 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(string.length()-chars)); }
RightExpression 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(string.length()-chars)); } }
RightExpression 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(string.length()-chars)); } RightExpression(String alias, Expression[] expressions); }
RightExpression 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(string.length()-chars)); } RightExpression(String alias, Expression[] expressions); @Override ExpressionResult apply(ExpressionContext context, ExpressionResult input); @Override String alias(); }
RightExpression 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(string.length()-chars)); } RightExpression(String alias, Expression[] expressions); @Override ExpressionResult apply(ExpressionContext context, ExpressionResult input); @Override String alias();  }