1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 */ 19 package org.eclipse.aether.repository; 20 21 import org.eclipse.aether.metadata.Metadata; 22 23 /** 24 * A query to the local repository for the existence of metadata. 25 * 26 * @see LocalRepositoryManager#find(org.eclipse.aether.RepositorySystemSession, LocalMetadataRequest) 27 */ 28 public final class LocalMetadataRequest { 29 30 private Metadata metadata; 31 32 private String context = ""; 33 34 private RemoteRepository repository = null; 35 36 /** 37 * Creates an uninitialized query. 38 */ 39 public LocalMetadataRequest() { 40 // enables default constructor 41 } 42 43 /** 44 * Creates a query with the specified properties. 45 * 46 * @param metadata The metadata to query for, may be {@code null}. 47 * @param repository The source remote repository for the metadata, may be {@code null} for local metadata. 48 * @param context The resolution context for the metadata, may be {@code null}. 49 */ 50 public LocalMetadataRequest(Metadata metadata, RemoteRepository repository, String context) { 51 setMetadata(metadata); 52 setRepository(repository); 53 setContext(context); 54 } 55 56 /** 57 * Gets the metadata to query for. 58 * 59 * @return The metadata or {@code null} if not set. 60 */ 61 public Metadata getMetadata() { 62 return metadata; 63 } 64 65 /** 66 * Sets the metadata to query for. 67 * 68 * @param metadata The metadata, may be {@code null}. 69 * @return This query for chaining, never {@code null}. 70 */ 71 public LocalMetadataRequest setMetadata(Metadata metadata) { 72 this.metadata = metadata; 73 return this; 74 } 75 76 /** 77 * Gets the resolution context. 78 * 79 * @return The resolution context, never {@code null}. 80 */ 81 public String getContext() { 82 return context; 83 } 84 85 /** 86 * Sets the resolution context. 87 * 88 * @param context The resolution context, may be {@code null}. 89 * @return This query for chaining, never {@code null}. 90 */ 91 public LocalMetadataRequest setContext(String context) { 92 this.context = (context != null) ? context : ""; 93 return this; 94 } 95 96 /** 97 * Gets the remote repository to use as source of the metadata. 98 * 99 * @return The remote repositories, may be {@code null} for local metadata. 100 */ 101 public RemoteRepository getRepository() { 102 return repository; 103 } 104 105 /** 106 * Sets the remote repository to use as sources of the metadata. 107 * 108 * @param repository The remote repository, may be {@code null}. 109 * @return This query for chaining, may be {@code null} for local metadata. 110 */ 111 public LocalMetadataRequest setRepository(RemoteRepository repository) { 112 this.repository = repository; 113 return this; 114 } 115 116 @Override 117 public String toString() { 118 return getMetadata() + " @ " + getRepository(); 119 } 120 }