1 package org.eclipse.aether.repository; 2 3 /* 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 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 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 19 * under the License. 20 */ 21 22 import org.eclipse.aether.RepositorySystemSession; 23 import org.eclipse.aether.metadata.Metadata; 24 25 /** 26 * A query to the local repository for the existence of metadata. 27 * 28 * @see LocalRepositoryManager#find(RepositorySystemSession, LocalMetadataRequest) 29 */ 30 public final class LocalMetadataRequest 31 { 32 33 private Metadata metadata; 34 35 private String context = ""; 36 37 private RemoteRepository repository = null; 38 39 /** 40 * Creates an uninitialized query. 41 */ 42 public LocalMetadataRequest() 43 { 44 // enables default constructor 45 } 46 47 /** 48 * Creates a query with the specified properties. 49 * 50 * @param metadata The metadata to query for, may be {@code null}. 51 * @param repository The source remote repository for the metadata, may be {@code null} for local metadata. 52 * @param context The resolution context for the metadata, may be {@code null}. 53 */ 54 public LocalMetadataRequest( Metadata metadata, RemoteRepository repository, String context ) 55 { 56 setMetadata( metadata ); 57 setRepository( repository ); 58 setContext( context ); 59 } 60 61 /** 62 * Gets the metadata to query for. 63 * 64 * @return The metadata or {@code null} if not set. 65 */ 66 public Metadata getMetadata() 67 { 68 return metadata; 69 } 70 71 /** 72 * Sets the metadata to query for. 73 * 74 * @param metadata The metadata, may be {@code null}. 75 * @return This query for chaining, never {@code null}. 76 */ 77 public LocalMetadataRequest setMetadata( Metadata metadata ) 78 { 79 this.metadata = metadata; 80 return this; 81 } 82 83 /** 84 * Gets the resolution context. 85 * 86 * @return The resolution context, never {@code null}. 87 */ 88 public String getContext() 89 { 90 return context; 91 } 92 93 /** 94 * Sets the resolution context. 95 * 96 * @param context The resolution context, may be {@code null}. 97 * @return This query for chaining, never {@code null}. 98 */ 99 public LocalMetadataRequest setContext( String context ) 100 { 101 this.context = ( context != null ) ? context : ""; 102 return this; 103 } 104 105 /** 106 * Gets the remote repository to use as source of the metadata. 107 * 108 * @return The remote repositories, may be {@code null} for local metadata. 109 */ 110 public RemoteRepository getRepository() 111 { 112 return repository; 113 } 114 115 /** 116 * Sets the remote repository to use as sources of the metadata. 117 * 118 * @param repository The remote repository, may be {@code null}. 119 * @return This query for chaining, may be {@code null} for local metadata. 120 */ 121 public LocalMetadataRequest setRepository( RemoteRepository repository ) 122 { 123 this.repository = repository; 124 return this; 125 } 126 127 @Override 128 public String toString() 129 { 130 return getMetadata() + " @ " + getRepository(); 131 } 132 133 }