]> git.argeo.org Git - lgpl/argeo-commons.git/blob - org.argeo.jcr/src/org/argeo/jcr/PropertyDiff.java
Factorise get image path.
[lgpl/argeo-commons.git] / org.argeo.jcr / src / org / argeo / jcr / PropertyDiff.java
1 package org.argeo.jcr;
2
3 import javax.jcr.Value;
4
5 /** The result of the comparison of two JCR properties. */
6 public class PropertyDiff {
7 public final static Integer MODIFIED = 0;
8 public final static Integer ADDED = 1;
9 public final static Integer REMOVED = 2;
10
11 private final Integer type;
12 private final String relPath;
13 private final Value referenceValue;
14 private final Value newValue;
15
16 public PropertyDiff(Integer type, String relPath, Value referenceValue, Value newValue) {
17 super();
18
19 if (type == MODIFIED) {
20 if (referenceValue == null || newValue == null)
21 throw new IllegalArgumentException("Reference and new values must be specified.");
22 } else if (type == ADDED) {
23 if (referenceValue != null || newValue == null)
24 throw new IllegalArgumentException("New value and only it must be specified.");
25 } else if (type == REMOVED) {
26 if (referenceValue == null || newValue != null)
27 throw new IllegalArgumentException("Reference value and only it must be specified.");
28 } else {
29 throw new IllegalArgumentException("Unkown diff type " + type);
30 }
31
32 if (relPath == null)
33 throw new IllegalArgumentException("Relative path must be specified");
34
35 this.type = type;
36 this.relPath = relPath;
37 this.referenceValue = referenceValue;
38 this.newValue = newValue;
39 }
40
41 public Integer getType() {
42 return type;
43 }
44
45 public String getRelPath() {
46 return relPath;
47 }
48
49 public Value getReferenceValue() {
50 return referenceValue;
51 }
52
53 public Value getNewValue() {
54 return newValue;
55 }
56
57 }