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