-
Notifications
You must be signed in to change notification settings - Fork 51
Mixins : ValueObject
johnmcclean-aol edited this page May 31, 2015
·
2 revisions
Implementing com.aol.cyclops.value.ValueObject in cyclops-core adds both Pattern Matching support and decomposition support to any object. It combines the Matchable interface and the Decomposable interface.
Any Object can be coerced to a ValueObject via the following methods
- AsValue.asValue
- As.asValue
With Lombok @Value
int result = As.asValue(new Child(10,20))._match(c->
c.isType( (Child child) -> child.value).with(__,20)));
//result is 20 (child.value)
@Value static class Child { int num,int value }