]>
git.argeo.org Git - gpl/argeo-slc.git/blob - org.argeo.slc.repo/src/org/eclipse/aether/metadata/DefaultMetadata.java
1 /*******************************************************************************
2 * Copyright (c) 2010, 2012 Sonatype, 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
9 * Sonatype, Inc. - initial API and implementation
10 *******************************************************************************/
11 package org
.eclipse
.aether
.metadata
;
17 * A basic metadata instance. <em>Note:</em> Instances of this class are immutable and the exposed mutators return new
18 * objects rather than changing the current instance.
20 public final class DefaultMetadata
21 extends AbstractMetadata
24 private final String groupId
;
26 private final String artifactId
;
28 private final String version
;
30 private final String type
;
32 private final Nature nature
;
34 private final File file
;
36 private final Map
<String
, String
> properties
;
39 * Creates a new metadata for the repository root with the specific type and nature.
41 * @param type The type of the metadata, e.g. "maven-metadata.xml", may be {@code null}.
42 * @param nature The nature of the metadata, must not be {@code null}.
44 public DefaultMetadata( String type
, Nature nature
)
46 this( "", "", "", type
, nature
, null, (File
) null );
50 * Creates a new metadata for the groupId level with the specific type and nature.
52 * @param groupId The group identifier to which this metadata applies, may be {@code null}.
53 * @param type The type of the metadata, e.g. "maven-metadata.xml", may be {@code null}.
54 * @param nature The nature of the metadata, must not be {@code null}.
56 public DefaultMetadata( String groupId
, String type
, Nature nature
)
58 this( groupId
, "", "", type
, nature
, null, (File
) null );
62 * Creates a new metadata for the groupId:artifactId level with the specific type and nature.
64 * @param groupId The group identifier to which this metadata applies, may be {@code null}.
65 * @param artifactId The artifact identifier to which this metadata applies, may be {@code null}.
66 * @param type The type of the metadata, e.g. "maven-metadata.xml", may be {@code null}.
67 * @param nature The nature of the metadata, must not be {@code null}.
69 public DefaultMetadata( String groupId
, String artifactId
, String type
, Nature nature
)
71 this( groupId
, artifactId
, "", type
, nature
, null, (File
) null );
75 * Creates a new metadata for the groupId:artifactId:version level with the specific type and nature.
77 * @param groupId The group identifier to which this metadata applies, may be {@code null}.
78 * @param artifactId The artifact identifier to which this metadata applies, may be {@code null}.
79 * @param version The version to which this metadata applies, may be {@code null}.
80 * @param type The type of the metadata, e.g. "maven-metadata.xml", may be {@code null}.
81 * @param nature The nature of the metadata, must not be {@code null}.
83 public DefaultMetadata( String groupId
, String artifactId
, String version
, String type
, Nature nature
)
85 this( groupId
, artifactId
, version
, type
, nature
, null, (File
) null );
89 * Creates a new metadata for the groupId:artifactId:version level with the specific type and nature.
91 * @param groupId The group identifier to which this metadata applies, may be {@code null}.
92 * @param artifactId The artifact identifier to which this metadata applies, may be {@code null}.
93 * @param version The version to which this metadata applies, may be {@code null}.
94 * @param type The type of the metadata, e.g. "maven-metadata.xml", may be {@code null}.
95 * @param nature The nature of the metadata, must not be {@code null}.
96 * @param file The resolved file of the metadata, may be {@code null}.
98 public DefaultMetadata( String groupId
, String artifactId
, String version
, String type
, Nature nature
, File file
)
100 this( groupId
, artifactId
, version
, type
, nature
, null, file
);
104 * Creates a new metadata for the groupId:artifactId:version level with the specific type and nature.
106 * @param groupId The group identifier to which this metadata applies, may be {@code null}.
107 * @param artifactId The artifact identifier to which this metadata applies, may be {@code null}.
108 * @param version The version to which this metadata applies, may be {@code null}.
109 * @param type The type of the metadata, e.g. "maven-metadata.xml", may be {@code null}.
110 * @param nature The nature of the metadata, must not be {@code null}.
111 * @param properties The properties of the metadata, may be {@code null} if none.
112 * @param file The resolved file of the metadata, may be {@code null}.
114 public DefaultMetadata( String groupId
, String artifactId
, String version
, String type
, Nature nature
,
115 Map
<String
, String
> properties
, File file
)
117 this.groupId
= emptify( groupId
);
118 this.artifactId
= emptify( artifactId
);
119 this.version
= emptify( version
);
120 this.type
= emptify( type
);
121 if ( nature
== null )
123 throw new IllegalArgumentException( "metadata nature was not specified" );
125 this.nature
= nature
;
127 this.properties
= copyProperties( properties
);
130 DefaultMetadata( String groupId
, String artifactId
, String version
, String type
, Nature nature
, File file
,
131 Map
<String
, String
> properties
)
133 // NOTE: This constructor assumes immutability of the provided properties, for internal use only
134 this.groupId
= emptify( groupId
);
135 this.artifactId
= emptify( artifactId
);
136 this.version
= emptify( version
);
137 this.type
= emptify( type
);
138 this.nature
= nature
;
140 this.properties
= properties
;
143 private static String
emptify( String str
)
145 return ( str
== null ) ?
"" : str
;
148 public String
getGroupId()
153 public String
getArtifactId()
158 public String
getVersion()
163 public String
getType()
168 public Nature
getNature()
173 public File
getFile()
178 public Map
<String
, String
> getProperties()