That’s the point, if your setters does not change the state, but create a new object and return it, then your encapsulation is not broken. Although one would argue that its not encapsulation. Its immutability.
Thats what map or filter does in a functional context, rather than mutating the existing array/collection, just return a new one.
Its exactly the same concept!