001package org.eclipse.aether.resolution; 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.repository.RemoteRepository; 023 024/** 025 * A query for the resolution error policy for a given artifact/metadata. 026 * 027 * @param <T> The type of the affected repository item (artifact or metadata). 028 * @see ResolutionErrorPolicy 029 */ 030public final class ResolutionErrorPolicyRequest<T> 031{ 032 033 private T item; 034 035 private RemoteRepository repository; 036 037 /** 038 * Creates an uninitialized request. 039 */ 040 public ResolutionErrorPolicyRequest() 041 { 042 // enables default constructor 043 } 044 045 /** 046 * Creates a request for the specified artifact/metadata and remote repository. 047 * 048 * @param item The artifact/metadata for which to determine the error policy, may be {@code null}. 049 * @param repository The repository from which the resolution is attempted, may be {@code null}. 050 */ 051 public ResolutionErrorPolicyRequest( T item, RemoteRepository repository ) 052 { 053 setItem( item ); 054 setRepository( repository ); 055 } 056 057 /** 058 * Gets the artifact/metadata for which to determine the error policy. 059 * 060 * @return The artifact/metadata for which to determine the error policy or {@code null} if not set. 061 */ 062 public T getItem() 063 { 064 return item; 065 } 066 067 /** 068 * Sets the artifact/metadata for which to determine the error policy. 069 * 070 * @param item The artifact/metadata for which to determine the error policy, may be {@code null}. 071 * @return This request for chaining, never {@code null}. 072 */ 073 public ResolutionErrorPolicyRequest<T> setItem( T item ) 074 { 075 this.item = item; 076 return this; 077 } 078 079 /** 080 * Gets the remote repository from which the resolution of the artifact/metadata is attempted. 081 * 082 * @return The involved remote repository or {@code null} if not set. 083 */ 084 public RemoteRepository getRepository() 085 { 086 return repository; 087 } 088 089 /** 090 * Sets the remote repository from which the resolution of the artifact/metadata is attempted. 091 * 092 * @param repository The repository from which the resolution is attempted, may be {@code null}. 093 * @return This request for chaining, never {@code null}. 094 */ 095 public ResolutionErrorPolicyRequest<T> setRepository( RemoteRepository repository ) 096 { 097 this.repository = repository; 098 return this; 099 } 100 101 @Override 102 public String toString() 103 { 104 return getItem() + " < " + getRepository(); 105 } 106 107}