-
Notifications
You must be signed in to change notification settings - Fork 188
/
ItemType.java
107 lines (91 loc) · 2.78 KB
/
ItemType.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
/*
* Copyright (c) 2019 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.prism.xml.ns._public.types_3;
import com.evolveum.midpoint.prism.*;
import com.evolveum.midpoint.prism.util.CloneUtil;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;
import javax.xml.namespace.QName;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
/**
* Experimental.
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "ItemType", propOrder = {
"name",
"value"
})
public class ItemType implements Serializable, JaxbVisitable {
protected QName name;
@Raw
protected final List<Object> value = new ArrayList<>();
public final static QName COMPLEX_TYPE = new QName(PrismConstants.NS_TYPES, "ItemType");
public final static QName F_NAME = new QName(PrismConstants.NS_TYPES, "name");
public final static QName F_VALUE = new QName(PrismConstants.NS_TYPES, "value");
public QName getName() {
return name;
}
public void setName(QName name) {
this.name = name;
}
public List<Object> getValue() {
return value;
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (!(o instanceof ItemType))
return false;
ItemType itemType = (ItemType) o;
return Objects.equals(name, itemType.name) &&
Objects.equals(getValue(), itemType.getValue());
}
@Override
public int hashCode() {
return Objects.hash(name, getValue());
}
@Override
public void accept(JaxbVisitor visitor) {
visitor.visit(this);
for (Object o : getValue()) {
if (o instanceof JaxbVisitable) {
visitor.visit((JaxbVisitable) o);
}
}
}
@SuppressWarnings("MethodDoesntCallSuperMethod")
public ItemType clone() {
ItemType clone = new ItemType();
clone.name = name;
for (Object v : getValue()) {
clone.getValue().add(CloneUtil.clone(v));
}
return clone;
}
@Override
public String toString() {
return "ItemType{" +
"name=" + name +
", value=" + value +
'}';
}
public static ItemType fromItem(Item item, PrismContext prismContext) {
if (item != null) {
ItemType rv = new ItemType();
rv.setName(item.getElementName());
rv.value.addAll(item.getRealValuesOrRawTypes(prismContext));
return rv;
} else {
return null;
}
}
}