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