-
Notifications
You must be signed in to change notification settings - Fork 188
/
PrismObject.java
192 lines (145 loc) · 5.97 KB
/
PrismObject.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
/*
* Copyright (c) 2010-2018 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.ChangeType;
import com.evolveum.midpoint.prism.delta.ItemDelta;
import com.evolveum.midpoint.prism.delta.ObjectDelta;
import com.evolveum.midpoint.prism.equivalence.ParameterizedEquivalenceStrategy;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.prism.polystring.PolyString;
import com.evolveum.midpoint.util.exception.SchemaException;
import org.jetbrains.annotations.NotNull;
import javax.xml.namespace.QName;
import java.util.Collection;
import java.util.List;
import java.util.function.Consumer;
import java.util.stream.Collectors;
/**
* Common supertype for all identity objects. Defines basic properties that each
* object must have to live in our system (identifier, name).
*
* Objects consists of identifier and name (see definition below) and a set of
* properties represented as XML elements in the object's body. The attributes
* are represented as first-level XML elements (tags) of the object XML
* representation and may be also contained in other tags (e.g. extension,
* attributes). The QName (namespace and local name) of the element holding the
* property is considered to be a property name.
*
* This class is named PrismObject instead of Object to avoid confusion with
* java.lang.Object.
*
* @author Radovan Semancik
*
* Class invariant: has at most one value (potentially empty).
* When making this object immutable and there's no value, we create one; in order
* to prevent exceptions on later getValue calls.
*/
public interface PrismObject<O extends Objectable> extends PrismContainer<O> {
// public PrismObject(QName name, Class<O> compileTimeClass) {
// super(name, compileTimeClass);
// }
//
// public PrismObject(QName name, Class<O> compileTimeClass, PrismContext prismContext) {
// super(name, compileTimeClass, prismContext);
// }
//
// public PrismObject(QName name, PrismObjectDefinition<O> definition, PrismContext prismContext) {
// super(name, definition, prismContext);
// }
PrismObjectValue<O> createNewValue();
@NotNull
PrismObjectValue<O> getValue();
@Override
void setValue(@NotNull PrismContainerValue<O> value) throws SchemaException;
/**
* Returns Object ID (OID).
*
* May return null if the object does not have an OID.
*
* @return Object ID (OID)
*/
String getOid();
void setOid(String oid);
String getVersion();
void setVersion(String version);
@Override
PrismObjectDefinition<O> getDefinition();
@NotNull
O asObjectable();
PolyString getName();
PrismContainer<?> getExtension();
PrismContainer<?> getOrCreateExtension() throws SchemaException;
PrismContainerValue<?> getExtensionContainerValue();
<I extends Item> I findExtensionItem(String elementLocalName);
<I extends Item> I findExtensionItem(QName elementName);
<I extends Item> void addExtensionItem(I item) throws SchemaException;
PrismContainer<?> createExtension() throws SchemaException;
@Override
void applyDefinition(PrismContainerDefinition<O> definition) throws SchemaException;
@Override
<IV extends PrismValue,ID extends ItemDefinition,I extends Item<IV,ID>> void removeItem(ItemPath path, Class<I> itemType);
void addReplaceExisting(Item<?, ?> item) throws SchemaException;
@Override
PrismObject<O> clone();
@Override
PrismObject<O> cloneComplex(CloneStrategy strategy);
PrismObjectDefinition<O> deepCloneDefinition(boolean ultraDeep, Consumer<ItemDefinition> postCloneAction);
@NotNull
ObjectDelta<O> diff(PrismObject<O> other);
@NotNull
ObjectDelta<O> diff(PrismObject<O> other, ParameterizedEquivalenceStrategy strategy);
@SuppressWarnings({ "rawtypes", "unchecked" })
Collection<? extends ItemDelta<?,?>> narrowModifications(Collection<? extends ItemDelta<?, ?>> modifications,
boolean assumeMissingItems);
ObjectDelta<O> createDelta(ChangeType changeType);
ObjectDelta<O> createAddDelta();
ObjectDelta<O> createModifyDelta();
ObjectDelta<O> createDeleteDelta();
@Override
void setParent(PrismContainerValue<?> parentValue);
@Override
PrismContainerValue<?> getParent();
/**
* this method ignores some part of the object during comparison (e.g. source demarcation in values)
* These methods compare the "meaningful" parts of the objects.
*/
boolean equivalent(Object obj);
/**
* Returns short string representing identity of this object.
* It should container object type, OID and name. It should be presented
* in a form suitable for log and diagnostic messages (understandable for
* system administrator).
*/
String toDebugName();
/**
* Returns short string identification of object type. It should be in a form
* suitable for log messages. There is no requirement for the type name to be unique,
* but it rather has to be compact. E.g. short element names are preferred to long
* QNames or URIs.
*/
String toDebugType();
/**
* Return display name intended for business users of midPoint
*/
String getBusinessDisplayName();
PrismObject<O> cloneIfImmutable();
PrismObject<O> createImmutableClone();
@NotNull
static <T extends Objectable> List<T> asObjectableList(@NotNull List<PrismObject<T>> objects) {
return objects.stream()
.map(o -> o.asObjectable())
.collect(Collectors.toList());
}
static PrismObject<?> asPrismObject(Objectable o) {
return o != null ? o.asPrismObject() : null;
}
static <T extends Objectable> T asObjectable(PrismObject<T> object) {
return object != null ? object.asObjectable() : null;
}
default void fixMockUpValueMetadata() {
}
}