I want to make immutables my DTO object. For that, I want to use http://immutables.github.io/.
I have the next legacy hierarchy:
public interface Interface1 extends Serializable{
public void method1();
}
public interface Interface2<T> extends Interface1{
public void method2();
}
public class Implementation1<T> implements Interface2<T>{
public void method1(){ }
public void method2(){
return null;
}
}
For keeping backward compatibility, I want to imeplements a new interface and implementation as given below:
@Value.Immutable
public Interface3<T> extends Interface2<T>{
public void method3();
}
That should generate ImmutableInterface3 class to be able to obtain a builder and to be able to build the class implementation.
The problem is that I can not use the next statement:
Interface3<Object> immutableImplementationOfInterface3 = ImmutableInterface3<Object>.builder().build();
Is there any problem with in this solution?
The solution is:
Interface3<Object> immutableImplementationOfInterface3 = ImmutableInterface3.<Object> builder().build();