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  import static java.util.Objects.requireNonNull;
24  
25  import org.eclipse.aether.RepositorySystemSession;
26  
27  /**
28   * A result from the local repository about the existence of metadata.
29   *
30   * @see LocalRepositoryManager#find(RepositorySystemSession, LocalMetadataRequest)
31   */
32  public final class LocalMetadataResult
33  {
34  
35      private final LocalMetadataRequest request;
36  
37      private File file;
38  
39      private boolean stale;
40  
41      /**
42       * Creates a new result for the specified request.
43       *
44       * @param request The local metadata request, must not be {@code null}.
45       */
46      public LocalMetadataResult( LocalMetadataRequest request )
47      {
48          this.request = requireNonNull( request, "local metadata request cannot be null" );
49      }
50  
51      /**
52       * Gets the request corresponding to this result.
53       *
54       * @return The corresponding request, never {@code null}.
55       */
56      public LocalMetadataRequest getRequest()
57      {
58          return request;
59      }
60  
61      /**
62       * Gets the file to the requested metadata if the metadata is available in the local repository.
63       * 
64       * @return The file to the requested metadata or {@code null}.
65       */
66      public File getFile()
67      {
68          return file;
69      }
70  
71      /**
72       * Sets the file to requested metadata.
73       * 
74       * @param file The metadata file, may be {@code null}.
75       * @return This result for chaining, never {@code null}.
76       */
77      public LocalMetadataResult setFile( File file )
78      {
79          this.file = file;
80          return this;
81      }
82  
83      /**
84       * This value indicates whether the metadata is stale and should be updated.
85       * 
86       * @return {@code true} if the metadata is stale and should be updated, {@code false} otherwise.
87       */
88      public boolean isStale()
89      {
90          return stale;
91      }
92  
93      /**
94       * Sets whether the metadata is stale.
95       * 
96       * @param stale {@code true} if the metadata is stale and should be updated, {@code false} otherwise.
97       * @return This result for chaining, never {@code null}.
98       */
99      public LocalMetadataResult setStale( boolean stale )
100     {
101         this.stale = stale;
102         return this;
103     }
104 
105     @Override
106     public String toString()
107     {
108         return request.toString() + "(" + getFile() + ")";
109     }
110 
111 }