1 package org.apache.archiva.repository.content.base;
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
22 import org.apache.archiva.repository.content.ItemSelector;
24 import java.util.Collections;
25 import java.util.HashMap;
29 * Item selector for querying artifacts and other content items.
31 public class ArchivaItemSelector implements ItemSelector
34 private String projectId = null;
35 private String version = null;
36 private String artifactVersion = null;
37 private String artifactId = null;
38 private String namespace = "";
39 private String type = null;
40 private String classifier = null;
41 private Map<String,String> attributes;
44 private ArchivaItemSelector() {
48 public static Builder builder() {
52 public static class Builder
54 private final ArchivaItemSelector selector = new ArchivaItemSelector( );
56 public Builder withNamespace( String namespace )
58 selector.namespace = namespace;
63 public Builder withProjectId( String projectId )
65 selector.projectId = projectId;
70 public Builder withVersion( String version )
72 selector.version = version;
77 public Builder withArtifactVersion( String artifactVersion )
79 selector.artifactVersion = artifactVersion;
84 public Builder withArtifactId( String artifactId )
86 selector.artifactId = artifactId;
91 public Builder withType( String type )
98 public Builder withClassifier( String classifier )
100 selector.classifier = classifier;
105 public Builder withAttribute( String key, String value )
107 selector.setAttribute( key, value );
111 public ArchivaItemSelector build() {
116 private void setAttribute(String key, String value) {
117 if (this.attributes == null) {
118 this.attributes = new HashMap<>( );
120 this.attributes.put( key, value );
124 public String getProjectId( )
130 public String getNamespace( )
136 public String getVersion( )
142 public String getArtifactVersion( )
144 return artifactVersion;
148 public String getArtifactId( )
154 public String getType( )
160 public String getClassifier( )
166 public String getAttribute( String key )
168 if ( this.attributes == null || !this.attributes.containsKey( key ) )
175 return this.attributes.get( key );
180 public Map<String, String> getAttributes( )
182 if (this.attributes==null) {
183 return Collections.emptyMap( );
185 return Collections.unmodifiableMap( this.attributes );
190 public boolean hasAttributes( )
192 return attributes!=null && attributes.size()>0;