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 org.eclipse.aether.RepositorySystemSession; 023import org.eclipse.aether.metadata.Metadata; 024 025/** 026 * A query to the local repository for the existence of metadata. 027 * 028 * @see LocalRepositoryManager#find(RepositorySystemSession, LocalMetadataRequest) 029 */ 030public final class LocalMetadataRequest 031{ 032 033 private Metadata metadata; 034 035 private String context = ""; 036 037 private RemoteRepository repository = null; 038 039 /** 040 * Creates an uninitialized query. 041 */ 042 public LocalMetadataRequest() 043 { 044 // enables default constructor 045 } 046 047 /** 048 * Creates a query with the specified properties. 049 * 050 * @param metadata The metadata to query for, may be {@code null}. 051 * @param repository The source remote repository for the metadata, may be {@code null} for local metadata. 052 * @param context The resolution context for the metadata, may be {@code null}. 053 */ 054 public LocalMetadataRequest( Metadata metadata, RemoteRepository repository, String context ) 055 { 056 setMetadata( metadata ); 057 setRepository( repository ); 058 setContext( context ); 059 } 060 061 /** 062 * Gets the metadata to query for. 063 * 064 * @return The metadata or {@code null} if not set. 065 */ 066 public Metadata getMetadata() 067 { 068 return metadata; 069 } 070 071 /** 072 * Sets the metadata to query for. 073 * 074 * @param metadata The metadata, may be {@code null}. 075 * @return This query for chaining, never {@code null}. 076 */ 077 public LocalMetadataRequest setMetadata( Metadata metadata ) 078 { 079 this.metadata = metadata; 080 return this; 081 } 082 083 /** 084 * Gets the resolution context. 085 * 086 * @return The resolution context, never {@code null}. 087 */ 088 public String getContext() 089 { 090 return context; 091 } 092 093 /** 094 * Sets the resolution context. 095 * 096 * @param context The resolution context, may be {@code null}. 097 * @return This query for chaining, never {@code null}. 098 */ 099 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}