1

I have default methods, such as setXxx(X x) and X getXxx(), but spring won't recoginze those as properties. Is it possible to somehow avoid method duplication if I want to use this interface in different classes?

Example:

public class Type {... }

public interface TypeSupport {
    Type getType();
    default String getTypeName(){ 
        return getType().getName(); 
    }
    default void setTypeName(String name){
        getType().setName(name);
    }
}

public class TypedVariable implements TypeSupport {
    private Type type = new Type();
    @Override public Type getType() {
        return type;
    }
}

I want to define TypedVariable bean in xml configuration:

<bean id="typedVariable" class="com.example.TypedVariable">
    <property name="typeName" value="string"/>
</bean>

When running, Spring fails with an error indicating that TypedVariable has no writeable property typeName.

Askar Kalykov
  • 2,553
  • 1
  • 22
  • 43
  • Spring is actually uses java bean utilities to lookup for properties. The same question is here http://stackoverflow.com/questions/23219006/default-method-in-interface-in-java-8-and-bean-info-introspector – Askar Kalykov Jul 10 '15 at 08:02

0 Answers0