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 java.io.File; 023 024import org.eclipse.aether.RepositorySystemSession; 025 026/** 027 * A result from the local repository about the existence of metadata. 028 * 029 * @see LocalRepositoryManager#find(RepositorySystemSession, LocalMetadataRequest) 030 */ 031public final class LocalMetadataResult 032{ 033 034 private final LocalMetadataRequest request; 035 036 private File file; 037 038 private boolean stale; 039 040 /** 041 * Creates a new result for the specified request. 042 * 043 * @param request The local metadata request, must not be {@code null}. 044 */ 045 public LocalMetadataResult( LocalMetadataRequest request ) 046 { 047 if ( request == null ) 048 { 049 throw new IllegalArgumentException( "local metadata request has not been specified" ); 050 } 051 this.request = request; 052 } 053 054 /** 055 * Gets the request corresponding to this result. 056 * 057 * @return The corresponding request, never {@code null}. 058 */ 059 public LocalMetadataRequest getRequest() 060 { 061 return request; 062 } 063 064 /** 065 * Gets the file to the requested metadata if the metadata is available in the local repository. 066 * 067 * @return The file to the requested metadata or {@code null}. 068 */ 069 public File getFile() 070 { 071 return file; 072 } 073 074 /** 075 * Sets the file to requested metadata. 076 * 077 * @param file The metadata file, may be {@code null}. 078 * @return This result for chaining, never {@code null}. 079 */ 080 public LocalMetadataResult setFile( File file ) 081 { 082 this.file = file; 083 return this; 084 } 085 086 /** 087 * This value indicates whether the metadata is stale and should be updated. 088 * 089 * @return {@code true} if the metadata is stale and should be updated, {@code false} otherwise. 090 */ 091 public boolean isStale() 092 { 093 return stale; 094 } 095 096 /** 097 * Sets whether the metadata is stale. 098 * 099 * @param stale {@code true} if the metadata is stale and should be updated, {@code false} otherwise. 100 * @return This result for chaining, never {@code null}. 101 */ 102 public LocalMetadataResult setStale( boolean stale ) 103 { 104 this.stale = stale; 105 return this; 106 } 107 108 @Override 109 public String toString() 110 { 111 return request.toString() + "(" + getFile() + ")"; 112 } 113 114}