Package: ArtifactSpecification

ArtifactSpecification

nameinstructionbranchcomplexitylinemethod
ArtifactSpecification(String, String, VersionRange)
M: 8 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
ArtifactSpecification(String, String, VersionRange, Map)
M: 8 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
ArtifactSpecification(String, String, VersionRange, URI, Map)
M: 23 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 7 C: 0
0%
M: 1 C: 0
0%
ArtifactSpecification(URI)
M: 8 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
ArtifactSpecification(URI, Map)
M: 8 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
getName()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getProperties()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getType()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getUri()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getVersionRange()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
static {...}
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2008, 2012 VMware Inc.
3: * All rights reserved. This program and the accompanying materials
4: * are made available under the terms of the Eclipse Public License v1.0
5: * which accompanies this distribution, and is available at
6: * http://www.eclipse.org/legal/epl-v10.html
7: *
8: * Contributors:
9: * VMware Inc. - initial contribution
10: *******************************************************************************/
11:
12: package org.eclipse.virgo.kernel.artifact;
13:
14: import java.net.URI;
15: import java.util.Collections;
16: import java.util.Map;
17:
18: import org.eclipse.virgo.nano.serviceability.NonNull;
19: import org.eclipse.virgo.util.osgi.manifest.VersionRange;
20:
21: /**
22: * An <code>ArtifactSpecification</code> is a reference to an artifact by type, name and version <i>range</i> or URI,
23: * but not both, together with some properties.
24: * <p />
25: *
26: * <strong>Concurrent Semantics</strong><br />
27: * Thread-safe.
28: *
29: */
30: public final class ArtifactSpecification {
31:
32: private static final Map<String, String> IMMUTABLE_EMPTY_MAP = Collections.<String, String> emptyMap();
33:
34: private final String type;
35:
36: private final String name;
37:
38: private final VersionRange versionRange;
39:
40: private final URI uri;
41:
42: private final Map<String, String> properties;
43:
44: /**
45: * Constructs a {@link ArtifactSpecification} with the given type, name, version range and no properties.
46: *
47: * @param type the type of the artifact specification, which must not be <code>null</code>
48: * @param name the name of the artifact specification, which must not be <code>null</code>
49: * @param versionRange the version range of the artifact specification, which must not be <code>null</code>
50: */
51: public ArtifactSpecification(@NonNull String type, @NonNull String name, @NonNull VersionRange versionRange) {
52: this(type, name, versionRange, null, null);
53: }
54:
55: /**
56: * Constructs a {@link ArtifactSpecification} with the given type, name, version range, and properties.
57: *
58: * @param type the type of the artifact specification, which must not be <code>null</code>
59: * @param name the name of the artifact specification, which must not be <code>null</code>
60: * @param versionRange the version range of the artifact specification, which must not be <code>null</code>
61: * @param properties the properties of the artifact specification, which must not be <code>null</code>
62: */
63: public ArtifactSpecification(@NonNull String type, @NonNull String name, @NonNull VersionRange versionRange,
64: @NonNull Map<String, String> properties) {
65: this(type, name, versionRange, null, properties);
66: }
67:
68: /**
69: * Constructs a {@link ArtifactSpecification} with the given URI and with no properties.
70: *
71: * @param uri the URI of the artifact specification, which must not be <code>null</code>
72: */
73: public ArtifactSpecification(@NonNull URI uri) {
74: this(null, null, null, uri, null);
75: }
76:
77: /**
78: * Constructs a {@link ArtifactSpecification} with the given URI and with no properties.
79: *
80: * @param uri the URI of the artifact specification, which must not be <code>null</code>
81: * @param properties the properties of the artifact specification, which must not be <code>null</code>
82: */
83: public ArtifactSpecification(@NonNull URI uri, @NonNull Map<String, String> properties) {
84: this(null, null, null, uri, properties);
85: }
86:
87: /**
88: * Constructs a {@link ArtifactSpecification} with the given type, name, version range, URI, and properties.
89: * <p>
90: * Either the type, name, and version range must be non-<code>null</code> and the URI <code>null</code> or the URI
91: * must be non-<code>null</code> and the type, name, and version range <code>null</code>. The properties may be
92: * <code>null</code>.
93: *
94: * @param type the type of the artifact specification
95: * @param name the name of the artifact specification
96: * @param versionRange the version range of the artifact specification
97: * @param uri the URI of the artifact specification
98: * @param properties the properties of the artifact specification, which may be <code>null</code>
99: */
100: private ArtifactSpecification(String type, String name, VersionRange versionRange, URI uri, Map<String, String> properties) {
101: this.type = type;
102: this.name = name;
103: this.versionRange = versionRange;
104: this.uri = uri;
105:• this.properties = properties == null ? IMMUTABLE_EMPTY_MAP : Collections.unmodifiableMap(properties);
106: }
107:
108: /**
109: * Returns the type.
110: *
111: * @return the type, or <code>null</code> if this artifact specification is by URI
112: */
113: public String getType() {
114: return this.type;
115: }
116:
117: /**
118: * Returns the name.
119: *
120: * @return the name, or <code>null</code> if this artifact specification is by URI
121: */
122: public String getName() {
123: return this.name;
124: }
125:
126: /**
127: * Returns the version range.
128: *
129: * @return a {@link VersionRange}, or <code>null</code> if this artifact specification is by URI
130: */
131: public VersionRange getVersionRange() {
132: return this.versionRange;
133: }
134:
135: /**
136: * Returns the URI. If a URI was not specified, returns <code>null</code>.
137: *
138: * @return a {@link URI} or <code>null</code> if this artifact specification is by type, name, and version range
139: */
140: public URI getUri() {
141: return this.uri;
142: }
143:
144: /**
145: * Returns the properties. If properties were not specified, returns an empty map. The returned properties may not
146: * be modified.
147: *
148: * @return a properties map, never <code>null</code>
149: */
150: public Map<String, String> getProperties() {
151: return this.properties;
152: }
153:
154: }