Suppose I have this class:
class Dependency{
public Dependency reverse() { ... } // returns this Dependency after some reverse OP
public int doSomething(int param) { ... }
}
Can I use it like this:
Optional<Integer> opt = ...
Dependency dep = new Dependency();
opt.map(dep::reverse::doSomething);
This would be quite clean, but is it possible? To apply a transformation (reverse) to Dependency and then apply the doSomething method?
mapcalls.opt.map(...).map(...). Not exactly sure though what you are attempting to do here. It would help if you could show a working code snippet, even if it is not as elegant as you would like it to be. Just to understand your scenario.reverse()modifies theDependencyinstance? Then, why not change the declaration toDependency dep = new Dependency().reverse();?