Example usage for java.util.function UnaryOperator andThen

List of usage examples for java.util.function UnaryOperator andThen

Introduction

In this page you can find the example usage for java.util.function UnaryOperator andThen.

Prototype

default <V> Function<T, V> andThen(Function<? super R, ? extends V> after) 

Source Link

Document

Returns a composed function that first applies this function to its input, and then applies the after function to the result.

Usage

From source file:com.liferay.dynamic.data.lists.form.web.internal.converter.DDLFormRuleToDDMFormRuleConverter.java

protected String convertOperand(DDLFormRuleCondition.Operand operand) {
    if (Objects.equals("field", operand.getType())) {
        return String.format(_functionCallUnaryExpressionFormat, "getValue",
                StringUtil.quote(operand.getValue()));
    }/*from  w  ww .ja  v  a 2s .com*/

    String value = operand.getValue();

    if (NumberUtils.isNumber(value)) {
        return value;
    }

    String[] values = StringUtil.split(value);

    UnaryOperator<String> quoteOperation = StringUtil::quote;
    UnaryOperator<String> trimOperation = StringUtil::trim;

    Stream<String> valuesStream = Stream.of(values);

    Stream<String> valueStream = valuesStream.map(trimOperation.andThen(quoteOperation));

    return valueStream.collect(Collectors.joining(StringPool.COMMA_AND_SPACE));
}