View Javadoc
1   package org.eclipse.aether.repository;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   * 
12   *  http://www.apache.org/licenses/LICENSE-2.0
13   * 
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.io.File;
23  
24  import org.eclipse.aether.RepositorySystemSession;
25  
26  /**
27   * A result from the local repository about the existence of metadata.
28   * 
29   * @see LocalRepositoryManager#find(RepositorySystemSession, LocalMetadataRequest)
30   */
31  public final class LocalMetadataResult
32  {
33  
34      private final LocalMetadataRequest request;
35  
36      private File file;
37  
38      private boolean stale;
39  
40      /**
41       * Creates a new result for the specified request.
42       * 
43       * @param request The local metadata request, must not be {@code null}.
44       */
45      public LocalMetadataResult( LocalMetadataRequest request )
46      {
47          if ( request == null )
48          {
49              throw new IllegalArgumentException( "local metadata request has not been specified" );
50          }
51          this.request = request;
52      }
53  
54      /**
55       * Gets the request corresponding to this result.
56       * 
57       * @return The corresponding request, never {@code null}.
58       */
59      public LocalMetadataRequest getRequest()
60      {
61          return request;
62      }
63  
64      /**
65       * Gets the file to the requested metadata if the metadata is available in the local repository.
66       * 
67       * @return The file to the requested metadata or {@code null}.
68       */
69      public File getFile()
70      {
71          return file;
72      }
73  
74      /**
75       * Sets the file to requested metadata.
76       * 
77       * @param file The metadata file, may be {@code null}.
78       * @return This result for chaining, never {@code null}.
79       */
80      public LocalMetadataResult setFile( File file )
81      {
82          this.file = file;
83          return this;
84      }
85  
86      /**
87       * This value indicates whether the metadata is stale and should be updated.
88       * 
89       * @return {@code true} if the metadata is stale and should be updated, {@code false} otherwise.
90       */
91      public boolean isStale()
92      {
93          return stale;
94      }
95  
96      /**
97       * Sets whether the metadata is stale.
98       * 
99       * @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 }