X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=server%2Fruntime%2Forg.argeo.server.jcr%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fjcr%2FPropertyDiff.java;fp=server%2Fruntime%2Forg.argeo.server.jcr%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fjcr%2FPropertyDiff.java;h=67e5d8ac67d28b52a01be8e1c6317b54c878e040;hb=5b81c294ae7541cc6a2a5867d1e1e8aa7f4358b5;hp=0000000000000000000000000000000000000000;hpb=becc04bd8ec12d2c2b7144e1605ae3eb37021164;p=lgpl%2Fargeo-commons.git diff --git a/server/runtime/org.argeo.server.jcr/src/main/java/org/argeo/jcr/PropertyDiff.java b/server/runtime/org.argeo.server.jcr/src/main/java/org/argeo/jcr/PropertyDiff.java new file mode 100644 index 000000000..67e5d8ac6 --- /dev/null +++ b/server/runtime/org.argeo.server.jcr/src/main/java/org/argeo/jcr/PropertyDiff.java @@ -0,0 +1,63 @@ +package org.argeo.jcr; + +import javax.jcr.Value; + +import org.argeo.ArgeoException; + +/** The result of the comparison of two JCR properties. */ +public class PropertyDiff { + public final static Integer MODIFIED = 0; + public final static Integer ADDED = 1; + public final static Integer REMOVED = 2; + + private final Integer type; + private final String relPath; + private final Value referenceValue; + private final Value newValue; + + public PropertyDiff(Integer type, String relPath, Value referenceValue, + Value newValue) { + super(); + + if (type == MODIFIED) { + if (referenceValue == null || newValue == null) + throw new ArgeoException( + "Reference and new values must be specified."); + } else if (type == ADDED) { + if (referenceValue != null || newValue == null) + throw new ArgeoException( + "New value and only it must be specified."); + } else if (type == REMOVED) { + if (referenceValue == null || newValue != null) + throw new ArgeoException( + "Reference value and only it must be specified."); + } else { + throw new ArgeoException("Unkown diff type " + type); + } + + if (relPath == null) + throw new ArgeoException("Relative path must be specified"); + + this.type = type; + this.relPath = relPath; + this.referenceValue = referenceValue; + this.newValue = newValue; + } + + public Integer getType() { + return type; + } + + public String getRelPath() { + return relPath; + } + + public Value getReferenceValue() { + return referenceValue; + } + + public Value getNewValue() { + return newValue; + } + +}