public UpdateItemSpec withExpected(Collection<Expected> expected) { if (expected == null) { this.expected = null; return this; } Set<String> names = new LinkedHashSet<String>(); for (Expected e : expected) names.add(e.getAttribute()); if (names.size() != expected.size()) { throw new IllegalArgumentException( "attribute names must not duplicate in the list of expected"); } this.expected = Collections.unmodifiableCollection(expected); return this; }