]>
git.argeo.org Git - gpl/argeo-slc.git/blob - org.argeo.slc.repo/src/org/eclipse/aether/artifact/DefaultArtifactType.java
1 /*******************************************************************************
2 * Copyright (c) 2010, 2013 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
.artifact
;
13 import java
.util
.Collections
;
14 import java
.util
.HashMap
;
18 * A simple artifact type.
20 public final class DefaultArtifactType
21 implements ArtifactType
24 private final String id
;
26 private final String extension
;
28 private final String classifier
;
30 private final Map
<String
, String
> properties
;
33 * Creates a new artifact type with the specified identifier. This constructor assumes the usual file extension
34 * equals the given type id and that the usual classifier is empty. Additionally, the properties
35 * {@link ArtifactProperties#LANGUAGE}, {@link ArtifactProperties#CONSTITUTES_BUILD_PATH} and
36 * {@link ArtifactProperties#INCLUDES_DEPENDENCIES} will be set to {@code "none"}, {@code true} and {@code false},
39 * @param id The identifier of the type which will also be used as the value for the {@link ArtifactProperties#TYPE}
40 * property, must not be {@code null} or empty.
42 public DefaultArtifactType( String id
)
44 this( id
, id
, "", "none", false, false );
48 * Creates a new artifact type with the specified properties. Additionally, the properties
49 * {@link ArtifactProperties#CONSTITUTES_BUILD_PATH} and {@link ArtifactProperties#INCLUDES_DEPENDENCIES} will be
50 * set to {@code true} and {@code false}, respectively.
52 * @param id The identifier of the type which will also be used as the value for the {@link ArtifactProperties#TYPE}
53 * property, must not be {@code null} or empty.
54 * @param extension The usual file extension for artifacts of this type, may be {@code null}.
55 * @param classifier The usual classifier for artifacts of this type, may be {@code null}.
56 * @param language The value for the {@link ArtifactProperties#LANGUAGE} property, may be {@code null}.
58 public DefaultArtifactType( String id
, String extension
, String classifier
, String language
)
60 this( id
, extension
, classifier
, language
, true, false );
64 * Creates a new artifact type with the specified properties.
66 * @param id The identifier of the type which will also be used as the value for the {@link ArtifactProperties#TYPE}
67 * property, must not be {@code null} or empty.
68 * @param extension The usual file extension for artifacts of this type, may be {@code null}.
69 * @param classifier The usual classifier for artifacts of this type, may be {@code null}.
70 * @param language The value for the {@link ArtifactProperties#LANGUAGE} property, may be {@code null}.
71 * @param constitutesBuildPath The value for the {@link ArtifactProperties#CONSTITUTES_BUILD_PATH} property.
72 * @param includesDependencies The value for the {@link ArtifactProperties#INCLUDES_DEPENDENCIES} property.
74 public DefaultArtifactType( String id
, String extension
, String classifier
, String language
,
75 boolean constitutesBuildPath
, boolean includesDependencies
)
77 if ( id
== null || id
.length() < 0 )
79 throw new IllegalArgumentException( "no type id specified" );
82 this.extension
= emptify( extension
);
83 this.classifier
= emptify( classifier
);
84 Map
<String
, String
> props
= new HashMap
<String
, String
>();
85 props
.put( ArtifactProperties
.TYPE
, id
);
86 props
.put( ArtifactProperties
.LANGUAGE
, ( language
!= null && language
.length() > 0 ) ? language
: "none" );
87 props
.put( ArtifactProperties
.INCLUDES_DEPENDENCIES
, Boolean
.toString( includesDependencies
) );
88 props
.put( ArtifactProperties
.CONSTITUTES_BUILD_PATH
, Boolean
.toString( constitutesBuildPath
) );
89 properties
= Collections
.unmodifiableMap( props
);
93 * Creates a new artifact type with the specified properties.
95 * @param id The identifier of the type, must not be {@code null} or empty.
96 * @param extension The usual file extension for artifacts of this type, may be {@code null}.
97 * @param classifier The usual classifier for artifacts of this type, may be {@code null}.
98 * @param properties The properties for artifacts of this type, may be {@code null}.
100 public DefaultArtifactType( String id
, String extension
, String classifier
, Map
<String
, String
> properties
)
102 if ( id
== null || id
.length() < 0 )
104 throw new IllegalArgumentException( "no type id specified" );
107 this.extension
= emptify( extension
);
108 this.classifier
= emptify( classifier
);
109 this.properties
= AbstractArtifact
.copyProperties( properties
);
112 private static String
emptify( String str
)
114 return ( str
== null ) ?
"" : str
;
117 public String
getId()
122 public String
getExtension()
127 public String
getClassifier()
132 public Map
<String
, String
> getProperties()