/** * Marshalls the give FEEL value into a String. The result is similar to * calling the string() function in a FEEL expression, with the difference * that a null value is returned as the "null" string instead of the null * value itself. * * @param value the FEEL value to be marshalled * * @return the string representation of the value */ @Override public String marshall(Object value) { if( value == null ) { return "null"; } return BuiltInFunctions.getFunction( StringFunction.class ).invoke( value ).cata( justNull(), Function.identity()); }
/** * Marshalls the given value into FEEL code that can be executed to * reconstruct the value. For instance, here are some examples of the marshalling process: * * * number 10 marshalls as: 10 * * string foo marshalls as: "foo" * * duration P1D marshalls as: duration( "P1D" ) * * context { x : 10, y : foo } marshalls as: { x : 10, y : "foo" } * * @param value the FEEL value to be marshalled * * @return a string representing the FEEL code that needs to be executed to reconstruct the value */ @Override public String marshall(Object value) { if( value == null ) { return "null"; } return KieExtendedDMNFunctions.getFunction(CodeFunction.class).invoke(value).cata(justNull(), Function.identity()); }
return null; } else if ( feelType.equals( org.kie.dmn.feel.lang.types.BuiltInType.NUMBER ) ) { return BuiltInFunctions.getFunction( NumberFunction.class ).invoke( value, null, null ).cata( justNull(), Function.identity() ); } else if ( feelType.equals( org.kie.dmn.feel.lang.types.BuiltInType.STRING ) ) { return value; } else if ( feelType.equals( org.kie.dmn.feel.lang.types.BuiltInType.DATE ) ) { return BuiltInFunctions.getFunction( DateFunction.class ).invoke( value ).cata( justNull(), Function.identity() ); } else if ( feelType.equals( org.kie.dmn.feel.lang.types.BuiltInType.TIME ) ) { return BuiltInFunctions.getFunction( TimeFunction.class ).invoke( value ).cata( justNull(), Function.identity() ); } else if ( feelType.equals( org.kie.dmn.feel.lang.types.BuiltInType.DATE_TIME ) ) { return BuiltInFunctions.getFunction( DateAndTimeFunction.class ).invoke( value ).cata( justNull(), Function.identity() ); } else if ( feelType.equals( org.kie.dmn.feel.lang.types.BuiltInType.DURATION ) ) { return BuiltInFunctions.getFunction( DurationFunction.class ).invoke( value ).cata( justNull(), Function.identity() ); } else if ( feelType.equals( org.kie.dmn.feel.lang.types.BuiltInType.BOOLEAN ) ) { return Boolean.parseBoolean( value );