I have an interface that defines a setter/getter using java 8 default methods, but I am getting an error when attempting to wire it up in Spring. I really want to avoid using abstract class and I don't want to duplicate the code. Here is what I am doing:
public interface MyProcessor
{
public static final WeakHashMap<Function1D, Integer> paramMap = new WeakHashMap<>();
default void setParam(int param)
{
paramMap.put(this, param);
}
default int getParam()
{
return paramMap.get(this);
}
default double doSomthingWithParam(double x)
{
return doSomething() * getParam();
}
double doSomething();
}
public class MyProcessorImp extends SomeClass implements MyProcessor
{
double doSomething() {....}
}
<bean class="....MyProcessorImp"> <property name="param" value="3"/></bean>
Bean property 'param' is not writable or has an invalid setter method.