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.Project;
23 import org.apache.archiva.repository.content.Version;
24 import org.apache.archiva.repository.storage.StorageAsset;
25 import org.apache.commons.lang3.StringUtils;
27 public class ArchivaVersion extends ArchivaContentItem implements Version
30 private String version;
31 private StorageAsset asset;
32 private Project project;
34 private ArchivaVersion() {
38 public static ProjectBuilder withVersion(String version) {
39 return new Builder( ).withVersion( version );
43 public String getVersion( )
49 public StorageAsset getAsset( )
55 public Project getProject( )
60 public interface ProjectBuilder {
61 Builder withProject( Project project );
64 public static final class Builder implements ProjectBuilder {
66 private ArchivaVersion version = new ArchivaVersion();
68 ProjectBuilder withVersion( String version )
70 if ( StringUtils.isEmpty( version ) ) {
71 throw new IllegalArgumentException( "Version parameter must not be empty or null." );
73 this.version.version = version;
79 public Builder withProject( Project project )
81 this.version.project = project;
85 public Builder withAsset( StorageAsset asset )
87 this.version.asset = asset;
91 public Builder withAttribute(String key, String value) {
92 this.version.putAttribute( key, value );
96 public ArchivaVersion build() {
97 if (this.version.asset == null) {
98 this.version.project.getAsset( );