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.artifact.Artifact; 023 024/** 025 * A query for the error policy for a given artifact's descriptor. 026 * 027 * @see ArtifactDescriptorPolicy 028 */ 029public final class ArtifactDescriptorPolicyRequest 030{ 031 032 private Artifact artifact; 033 034 private String context = ""; 035 036 /** 037 * Creates an uninitialized request. 038 */ 039 public ArtifactDescriptorPolicyRequest() 040 { 041 // enables default constructor 042 } 043 044 /** 045 * Creates a request for the specified artifact. 046 * 047 * @param artifact The artifact for whose descriptor to determine the error policy, may be {@code null}. 048 * @param context The context in which this request is made, may be {@code null}. 049 */ 050 public ArtifactDescriptorPolicyRequest( Artifact artifact, String context ) 051 { 052 setArtifact( artifact ); 053 setRequestContext( context ); 054 } 055 056 /** 057 * Gets the artifact for whose descriptor to determine the error policy. 058 * 059 * @return The artifact for whose descriptor to determine the error policy or {@code null} if not set. 060 */ 061 public Artifact getArtifact() 062 { 063 return artifact; 064 } 065 066 /** 067 * Sets the artifact for whose descriptor to determine the error policy. 068 * 069 * @param artifact The artifact for whose descriptor to determine the error policy, may be {@code null}. 070 * @return This request for chaining, never {@code null}. 071 */ 072 public ArtifactDescriptorPolicyRequest setArtifact( Artifact artifact ) 073 { 074 this.artifact = artifact; 075 return this; 076 } 077 078 /** 079 * Gets the context in which this request is made. 080 * 081 * @return The context, never {@code null}. 082 */ 083 public String getRequestContext() 084 { 085 return context; 086 } 087 088 /** 089 * Sets the context in which this request is made. 090 * 091 * @param context The context, may be {@code null}. 092 * @return This request for chaining, never {@code null}. 093 */ 094 public ArtifactDescriptorPolicyRequest setRequestContext( String context ) 095 { 096 this.context = ( context != null ) ? context : ""; 097 return this; 098 } 099 100 @Override 101 public String toString() 102 { 103 return String.valueOf( getArtifact() ); 104 } 105 106}