View Javadoc
1   package org.pojomatic.diff;
2   
3   import java.util.Collections;
4   import java.util.List;
5   
6   import org.pojomatic.Pojomatic;
7   import org.pojomatic.annotations.Property;
8   
9   public class PropertyDifferences implements Differences {
10    @Property
11    private final List<Difference> differences;
12  
13    /**
14     * @param differences cannot be {@code null} or empty
15     * @throws NullPointerException if {@code differences} is {@code null}
16     * @throws IllegalArgumentException if {@code differences.isEmpty()} is {@code true}
17     */
18    public PropertyDifferences(List<Difference> differences) {
19      if (differences == null) {
20        throw new NullPointerException("list of differences is null");
21      }
22      if (differences.isEmpty()) {
23        throw new IllegalArgumentException("list of differences is empty");
24      }
25      this.differences = Collections.unmodifiableList(differences);
26    }
27  
28    @Override
29    public List<Difference> differences() {
30      return differences;
31    }
32  
33    @Override
34    public boolean areEqual() {
35      return false;
36    }
37  
38    @Override
39    public String toString() {
40      return differences.toString();
41    }
42  
43    @Override
44    public boolean equals(Object other) {
45      return Pojomatic.equals(this, other);
46    }
47  
48    @Override
49    public int hashCode() {
50      return Pojomatic.hashCode(this);
51    }
52  }