Array consisting of mutable objects is mutable which contradicts the project's documentation.
The following tests fails:
/**
* Array must be immutable
*/
@Test
public void isImmutable() {
final Mutable[] ints = new Mutable[]{new Mutable(1), new Mutable(2), new Mutable(3)};
final Array<Mutable> array = new Array<Mutable>(ints);
ints[1].setState(200);
Assert.assertTrue(
Arrays.equals(array.toArray(), new Mutable[]{new Mutable(1), new Mutable(2), new Mutable(3)})
);
}
public class Mutable {
Integer state;
public Mutable(Integer state) {
this.state = state;
}
public Integer getState() {
return state;
}
public void setState(Integer state) {
this.state = state;
}
@Override
public int hashCode() {
return state;
}
@Override
public boolean equals(Object obj) {
return state.equals(((Mutable)obj).getState());
}
}
Array consisting of mutable objects is mutable which contradicts the project's documentation.
The following tests fails: