-
Notifications
You must be signed in to change notification settings - Fork 188
/
PrismValue.java
193 lines (145 loc) · 6.27 KB
/
PrismValue.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
/*
* Copyright (c) 2010-2020 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
*/
package com.evolveum.midpoint.prism;
import com.evolveum.midpoint.prism.delta.ItemDelta;
import com.evolveum.midpoint.prism.equivalence.ParameterizedEquivalenceStrategy;
import com.evolveum.midpoint.prism.metadata.MidpointOriginMetadata;
import com.evolveum.midpoint.prism.equivalence.EquivalenceStrategy;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.util.DebugDumpable;
import com.evolveum.midpoint.util.annotation.Experimental;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.prism.xml.ns._public.types_3.RawType;
import com.google.common.annotations.VisibleForTesting;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.xml.namespace.QName;
import java.io.Serializable;
import java.util.Collection;
import java.util.Map;
import java.util.Optional;
/**
* @author semancik
*
*/
public interface PrismValue extends Visitable, PathVisitable, Serializable, DebugDumpable, Revivable, Freezable, PrismContextSensitive, MidpointOriginMetadata { // todo ShortDumpable?
@VisibleForTesting
void setPrismContext(PrismContext prismContext);
Map<String, Object> getUserData();
Object getUserData(@NotNull String key);
void setUserData(@NotNull String key, Object value);
Itemable getParent();
void setParent(Itemable parent);
@Experimental
Optional<ValueMetadata> valueMetadata() throws SchemaException;
/**
* Maybe it is better to expect empty value metadata if these are absent.
* Client code would be simpler. HIGHLY EXPERIMENTAL.
*/
@Experimental
ValueMetadata getValueMetadata() throws SchemaException;
@Experimental
default void createLiveMetadata() {
}
@NotNull
ItemPath getPath();
/**
* Used when we are removing the value from the previous parent.
* Or when we know that the previous parent will be discarded and we
* want to avoid unnecessary cloning.
*/
void clearParent();
void applyDefinition(ItemDefinition definition) throws SchemaException;
void applyDefinition(ItemDefinition definition, boolean force) throws SchemaException;
/**
* Recompute the value or otherwise "initialize" it before adding it to a prism tree.
* This may as well do nothing if no recomputing or initialization is needed.
*/
void recompute();
void recompute(PrismContext prismContext);
@Override
void accept(Visitor visitor);
@Override
void accept(Visitor visitor, ItemPath path, boolean recursive);
void checkConsistenceInternal(Itemable rootItem, boolean requireDefinitions, boolean prohibitRaw, ConsistencyCheckScope scope);
/**
* Returns true if this and other value represent the same value.
* E.g. if they have the same IDs, OIDs or it is otherwise know
* that they "belong together" without a deep examination of the
* values.
*
* @param lax If we can reasonably assume that the two values belong together even if they don't have the same ID,
* e.g. if they both belong to single-valued parent items. This is useful e.g. when comparing
* multi-valued containers. But can cause problems when we want to be sure we are removing the correct
* value.
*/
boolean representsSameValue(PrismValue other, boolean lax);
void normalize();
/**
* Literal clone.
*/
PrismValue clone();
PrismValue createImmutableClone();
/**
* Complex clone with different cloning strategies.
* @see CloneStrategy
*/
PrismValue cloneComplex(CloneStrategy strategy);
int hashCode(@NotNull EquivalenceStrategy equivalenceStrategy);
int hashCode(@NotNull ParameterizedEquivalenceStrategy equivalenceStrategy);
boolean equals(PrismValue otherValue, @NotNull EquivalenceStrategy strategy);
boolean equals(PrismValue otherValue, @NotNull ParameterizedEquivalenceStrategy strategy);
// TODO: No caller found
@Deprecated
boolean equals(PrismValue thisValue, PrismValue otherValue);
/**
* Assumes matching representations. I.e. it assumes that both this and otherValue represent the same instance of item.
* E.g. the container with the same ID.
*/
Collection<? extends ItemDelta> diff(PrismValue otherValue);
/**
* Assumes matching representations. I.e. it assumes that both this and otherValue represent the same instance of item.
* E.g. the container with the same ID.
*/
Collection<? extends ItemDelta> diff(PrismValue otherValue, ParameterizedEquivalenceStrategy strategy);
@Nullable
Class<?> getRealClass();
@Experimental // todo reconsider method name
default boolean hasRealClass() {
return getRealClass() != null;
}
@Nullable
<T> T getRealValue();
@Nullable
@Experimental // todo reconsider method name
default Object getRealValueOrRawType(PrismContext prismContext) {
if (hasRealClass()) {
return getRealValue();
} else {
return new RawType(this, getTypeName(), prismContext);
}
}
// Returns a root of PrismValue tree. For example, if we have a AccessCertificationWorkItemType that has a parent (owner)
// of AccessCertificationCaseType, which has a parent of AccessCertificationCampaignType, this method returns the PCV
// of AccessCertificationCampaignType.
//
// Generally, this method returns either "this" (PrismValue) or a PrismContainerValue.
PrismValue getRootValue();
PrismContainerValue<?> getParentContainerValue();
QName getTypeName();
// Path may contain ambiguous segments (e.g. assignment/targetRef when there are more assignments)
// Note that the path can contain name segments only (at least for now)
@NotNull
Collection<PrismValue> getAllValues(ItemPath path);
boolean isRaw();
boolean isEmpty();
String toHumanReadableString();
// // todo hide from public
// void diffMatchingRepresentation(PrismValue otherValue,
// Collection<? extends ItemDelta> deltas, boolean ignoreMetadata, boolean isLiteral);
Object find(ItemPath path);
}