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