133 | | The following is an example of the tricky case: an inner class that calls methods in the parent class. |
| 133 | If the private class is a functional (eg Runnable, Predicate or Function), then a workaround method is to define an extraMethod in your class with the same signature (in/output) as the functional. Eg if you need a Function<String, Integer>, then define {{{private Integer extraMethod(String) {...} }}}, like this: |
| 134 | |
| 135 | |
| 136 | {{{ |
| 137 | class Parent { |
| 138 | ... |
| 139 | Function<String, Integer> f = new Function<String, Integer>() { |
| 140 | @Override |
| 141 | public Integer apply(String t) { |
| 142 | return 1; |
| 143 | }; |
| 144 | ... |
| 145 | use(f) |
| 146 | } |
| 147 | }}} |
| 148 | |
| 149 | |
| 150 | you can now replace this with |
| 151 | |
| 152 | {{{ |
| 153 | class Parent { |
| 154 | ... |
| 155 | private Integer extraMethod(String t) { |
| 156 | return 1 |
| 157 | } |
| 158 | |
| 159 | ... |
| 160 | use(this::extraMethod) |
| 161 | } |
| 162 | }}} |
| 163 | |
| 164 | |
| 165 | If the class you want to override is not a nice Functional, then it becomes more tricky. We recommend to create a separate class then |