I implemented a copy constructor that needed to do a deep copy of on of acollection
neither of my classes are implementing the clonable interaface (don't need this ^^ )
Lets pretend I have follwing both classes
public class Bar {
private int field1;
private String field2;
public Bar() {
}
public Bar(Bar other) {
this.field1 = other.field1;
this.field2 = other.field2;
}
}
public class Foo {
private List<Bar> bars;
public Foo() {
}
public Foo(Foo other) {
this.bars = other.bars
.stream()
.map(Bar::new)
.collect(Collectors.toList());
}
}
Basically the copy constructor of Foo is not doing any dark magic.
It makes a deep copy of the other object collection.
IMO the copy constructor of Foo class should not print any warning at all
I implemented a copy constructor that needed to do a deep copy of on of acollection
neither of my classes are implementing the clonable interaface (don't need this ^^ )
Lets pretend I have follwing both classes
Basically the copy constructor of Foo is not doing any dark magic.
It makes a deep copy of the other object collection.
IMO the copy constructor of Foo class should not print any warning at all