1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.opencastproject.assetmanager.api;
22
23 import static java.lang.String.format;
24
25 import org.opencastproject.util.RequireUtil;
26
27 import java.io.Serializable;
28 import java.util.Objects;
29
30 import javax.annotation.ParametersAreNonnullByDefault;
31 import javax.annotation.concurrent.Immutable;
32
33 @Immutable
34 @ParametersAreNonnullByDefault
35 public final class PropertyId implements Serializable {
36 private static final long serialVersionUID = -2614578081057869958L;
37
38 private final String mpId;
39 private final String namespace;
40 private final String name;
41
42
43
44
45 public PropertyId(String mpId, String namespace, String name) {
46 this.mpId = RequireUtil.notEmpty(mpId, "mpId");
47 this.namespace = RequireUtil.notEmpty(namespace, "namespace");
48 this.name = RequireUtil.notEmpty(name, "name");
49 }
50
51
52
53
54 public static PropertyId mk(String mpId, String namespace, String propertyName) {
55 return new PropertyId(mpId, namespace, propertyName);
56 }
57
58
59
60
61 public static PropertyId mk(String mpId, PropertyName fqn) {
62 return new PropertyId(mpId, fqn.getNamespace(), fqn.getName());
63 }
64
65 public String getMediaPackageId() {
66 return mpId;
67 }
68
69 public String getNamespace() {
70 return namespace;
71 }
72
73 public String getName() {
74 return name;
75 }
76
77 public PropertyName getFqn() {
78 return PropertyName.mk(namespace, name);
79 }
80
81
82
83 @Override public int hashCode() {
84 return Objects.hash(mpId, namespace, name);
85 }
86
87 @Override public boolean equals(Object that) {
88 return (this == that) || (that instanceof PropertyId && eqFields((PropertyId) that));
89 }
90
91 private boolean eqFields(PropertyId that) {
92 return Objects.equals(mpId, that.mpId)
93 && Objects.equals(namespace, that.namespace)
94 && Objects.equals(name, that.name);
95 }
96
97 @Override public String toString() {
98 return format("PropertyId(%s, %s, %s)", mpId, namespace, name);
99 }
100 }