001package org.eclipse.aether.repository; 002 003/* 004 * Licensed to the Apache Software Foundation (ASF) under one 005 * or more contributor license agreements. See the NOTICE file 006 * distributed with this work for additional information 007 * regarding copyright ownership. The ASF licenses this file 008 * to you under the Apache License, Version 2.0 (the 009 * "License"); you may not use this file except in compliance 010 * with the License. You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, 015 * software distributed under the License is distributed on an 016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 017 * KIND, either express or implied. See the License for the 018 * specific language governing permissions and limitations 019 * under the License. 020 */ 021 022import java.util.Collection; 023import java.util.Collections; 024 025import org.eclipse.aether.metadata.Metadata; 026 027/** 028 * A request to register metadata within the local repository. 029 * 030 * @see LocalRepositoryManager#add(org.eclipse.aether.RepositorySystemSession, LocalMetadataRegistration) 031 */ 032public final class LocalMetadataRegistration 033{ 034 035 private Metadata metadata; 036 037 private RemoteRepository repository; 038 039 private Collection<String> contexts = Collections.emptyList(); 040 041 /** 042 * Creates an uninitialized registration. 043 */ 044 public LocalMetadataRegistration() 045 { 046 // enables default constructor 047 } 048 049 /** 050 * Creates a registration request for the specified metadata accompanying a locally installed artifact. 051 * 052 * @param metadata The metadata to register, may be {@code null}. 053 */ 054 public LocalMetadataRegistration( Metadata metadata ) 055 { 056 setMetadata( metadata ); 057 } 058 059 /** 060 * Creates a registration request for the specified metadata. 061 * 062 * @param metadata The metadata to register, may be {@code null}. 063 * @param repository The remote repository from which the metadata was resolved or {@code null} if the metadata 064 * accompanies a locally installed artifact. 065 * @param contexts The resolution contexts, may be {@code null}. 066 */ 067 public LocalMetadataRegistration( Metadata metadata, RemoteRepository repository, Collection<String> contexts ) 068 { 069 setMetadata( metadata ); 070 setRepository( repository ); 071 setContexts( contexts ); 072 } 073 074 /** 075 * Gets the metadata to register. 076 * 077 * @return The metadata or {@code null} if not set. 078 */ 079 public Metadata getMetadata() 080 { 081 return metadata; 082 } 083 084 /** 085 * Sets the metadata to register. 086 * 087 * @param metadata The metadata, may be {@code null}. 088 * @return This request for chaining, never {@code null}. 089 */ 090 public LocalMetadataRegistration setMetadata( Metadata metadata ) 091 { 092 this.metadata = metadata; 093 return this; 094 } 095 096 /** 097 * Gets the remote repository from which the metadata was resolved. 098 * 099 * @return The remote repository or {@code null} if the metadata was locally installed. 100 */ 101 public RemoteRepository getRepository() 102 { 103 return repository; 104 } 105 106 /** 107 * Sets the remote repository from which the metadata was resolved. 108 * 109 * @param repository The remote repository or {@code null} if the metadata accompanies a locally installed artifact. 110 * @return This request for chaining, never {@code null}. 111 */ 112 public LocalMetadataRegistration setRepository( RemoteRepository repository ) 113 { 114 this.repository = repository; 115 return this; 116 } 117 118 /** 119 * Gets the resolution contexts in which the metadata is available. 120 * 121 * @return The resolution contexts in which the metadata is available, never {@code null}. 122 */ 123 public Collection<String> getContexts() 124 { 125 return contexts; 126 } 127 128 /** 129 * Sets the resolution contexts in which the metadata is available. 130 * 131 * @param contexts The resolution contexts, may be {@code null}. 132 * @return This request for chaining, never {@code null}. 133 */ 134 public LocalMetadataRegistration setContexts( Collection<String> contexts ) 135 { 136 if ( contexts != null ) 137 { 138 this.contexts = contexts; 139 } 140 else 141 { 142 this.contexts = Collections.emptyList(); 143 } 144 return this; 145 } 146 147}