I'm able to modify return type properties at runtime for primitive types and also direct pojo classes.
Working return types:
Method that returns types given below are working as expected.
primitives: boolean, string, integer
pojo:
public class Test
a.btm:
RULE a
CLASS com.test.ClassA
METHOD methodOne
AT EXIT
IF true
DO
<RULE ACTION> // 3 rule actions that's working as expecting
ENDRULE
Rule actions working for below 3 return types:
$!="manipulatedString"; // if method returns string type with value "string", this rule will modify to manipulatedString
(OR)
$!=5; // if method returns integer type with value in "2", this rule will modify to 5
ENDRULE (OR)
$!.setId(100);
$!.setText("modifiedText");
$!.setType(true); // if method returns type of class Test with value in {"id": 1, "text": "originalText", "type": false}, this rule will modify to {"id": 100, "text": "modifiedText", "type": true},
However, the same rule convention is not working for complex return types ie. ResponseEntity<Resource<User>> where the expectation is change one of the properties of ResponseEntity Or Resource Or User.
a.btm:
IMPORT org.springframework.http.ResponseEntity
IMPORT org.springframework.hateoas.Resource
IMPORT org.springframework.hateoas.Resources
IMPORT org.springframework.http.HttpStatus
IMPORT com.vmware.mangle.mysql.model.security.User
RULE a
CLASS com.vmware.mangle.services.controller.UserManagementController
METHOD getCurrentUser
AT EXIT
IF TRUE
DO
ResponseEntity<Resource<User>> responseEntity = $!;
HttpStatus httpStatus = responseEntity.getStatusCode();
if (httpStatus == HttpStatus.OK)
ENDRULE