Preparing your design workspace

Loading the problem and your saved attempt…

Design and Implement an Immutable Customer Profile

Build a Java value object whose scalar and collection state remains unchanged through retained inputs, accessors, and derived updates.

Design and implement an immutable Java CustomerProfile value object. For this exercise, each profile contains a nonblank string id, an ordered list of distinct string roles, a string-to-string attributes map, and a creation Instant. Construction must reject invalid input.

Later changes to caller-supplied collections must not change a profile, and values returned through its public API must not allow callers to change it. Callers can read every field and derive a profile with one added or replaced attribute, but the original profile must remain unchanged.

Define value equality and deterministic tests that attempt mutation through retained input references, accessors, and the derivation method. Assume strings and Instant are immutable.

Keep persistence, framework annotations, network serialization, authorization, profile merging, and mutable nested value types outside the first version.