]> git.argeo.org Git - gpl/argeo-slc.git/blob - LocalMetadataResult.java
6f3687a5ecebab3dba44ad55f68d4473e08fc8d4
[gpl/argeo-slc.git] / LocalMetadataResult.java
1 /*******************************************************************************
2 * Copyright (c) 2010, 2011 Sonatype, Inc.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 * Sonatype, Inc. - initial API and implementation
10 *******************************************************************************/
11 package org.eclipse.aether.repository;
12
13 import java.io.File;
14
15 import org.eclipse.aether.RepositorySystemSession;
16
17 /**
18 * A result from the local repository about the existence of metadata.
19 *
20 * @see LocalRepositoryManager#find(RepositorySystemSession, LocalMetadataRequest)
21 */
22 public final class LocalMetadataResult
23 {
24
25 private final LocalMetadataRequest request;
26
27 private File file;
28
29 private boolean stale;
30
31 /**
32 * Creates a new result for the specified request.
33 *
34 * @param request The local metadata request, must not be {@code null}.
35 */
36 public LocalMetadataResult( LocalMetadataRequest request )
37 {
38 if ( request == null )
39 {
40 throw new IllegalArgumentException( "local metadata request has not been specified" );
41 }
42 this.request = request;
43 }
44
45 /**
46 * Gets the request corresponding to this result.
47 *
48 * @return The corresponding request, never {@code null}.
49 */
50 public LocalMetadataRequest getRequest()
51 {
52 return request;
53 }
54
55 /**
56 * Gets the file to the requested metadata if the metadata is available in the local repository.
57 *
58 * @return The file to the requested metadata or {@code null}.
59 */
60 public File getFile()
61 {
62 return file;
63 }
64
65 /**
66 * Sets the file to requested metadata.
67 *
68 * @param file The metadata file, may be {@code null}.
69 * @return This result for chaining, never {@code null}.
70 */
71 public LocalMetadataResult setFile( File file )
72 {
73 this.file = file;
74 return this;
75 }
76
77 /**
78 * This value indicates whether the metadata is stale and should be updated.
79 *
80 * @return {@code true} if the metadata is stale and should be updated, {@code false} otherwise.
81 */
82 public boolean isStale()
83 {
84 return stale;
85 }
86
87 /**
88 * Sets whether the metadata is stale.
89 *
90 * @param stale {@code true} if the metadata is stale and should be updated, {@code false} otherwise.
91 * @return This result for chaining, never {@code null}.
92 */
93 public LocalMetadataResult setStale( boolean stale )
94 {
95 this.stale = stale;
96 return this;
97 }
98
99 @Override
100 public String toString()
101 {
102 return request.toString() + "(" + getFile() + ")";
103 }
104
105 }