001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 */ 019package org.eclipse.aether.repository; 020 021import org.eclipse.aether.metadata.Metadata; 022 023/** 024 * A query to the local repository for the existence of metadata. 025 * 026 * @see LocalRepositoryManager#find(org.eclipse.aether.RepositorySystemSession, LocalMetadataRequest) 027 */ 028public final class LocalMetadataRequest { 029 030 private Metadata metadata; 031 032 private String context = ""; 033 034 private RemoteRepository repository = null; 035 036 /** 037 * Creates an uninitialized query. 038 */ 039 public LocalMetadataRequest() { 040 // enables default constructor 041 } 042 043 /** 044 * Creates a query with the specified properties. 045 * 046 * @param metadata The metadata to query for, may be {@code null}. 047 * @param repository The source remote repository for the metadata, may be {@code null} for local metadata. 048 * @param context The resolution context for the metadata, may be {@code null}. 049 */ 050 public LocalMetadataRequest(Metadata metadata, RemoteRepository repository, String context) { 051 setMetadata(metadata); 052 setRepository(repository); 053 setContext(context); 054 } 055 056 /** 057 * Gets the metadata to query for. 058 * 059 * @return The metadata or {@code null} if not set. 060 */ 061 public Metadata getMetadata() { 062 return metadata; 063 } 064 065 /** 066 * Sets the metadata to query for. 067 * 068 * @param metadata The metadata, may be {@code null}. 069 * @return This query for chaining, never {@code null}. 070 */ 071 public LocalMetadataRequest setMetadata(Metadata metadata) { 072 this.metadata = metadata; 073 return this; 074 } 075 076 /** 077 * Gets the resolution context. 078 * 079 * @return The resolution context, never {@code null}. 080 */ 081 public String getContext() { 082 return context; 083 } 084 085 /** 086 * Sets the resolution context. 087 * 088 * @param context The resolution context, may be {@code null}. 089 * @return This query for chaining, never {@code null}. 090 */ 091 public LocalMetadataRequest setContext(String context) { 092 this.context = (context != null) ? context : ""; 093 return this; 094 } 095 096 /** 097 * Gets the remote repository to use as source of the metadata. 098 * 099 * @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}