View Javadoc

1   package org.sonatype.aether.metadata;
2   
3   /*******************************************************************************
4    * Copyright (c) 2010-2011 Sonatype, Inc.
5    * All rights reserved. This program and the accompanying materials
6    * are made available under the terms of the Eclipse Public License v1.0
7    * which accompanies this distribution, and is available at
8    *   http://www.eclipse.org/legal/epl-v10.html
9    *******************************************************************************/
10  
11  import java.io.File;
12  
13  /**
14   * A piece of repository metadata, e.g. an index of available versions. In contrast to an artifact, which usually exists
15   * in only one repository, metadata usually exists in multiple repositories and each repository contains a different
16   * copy of the metadata. <em>Note:</em> Metadata instances are supposed to be immutable, e.g. any exposed mutator method
17   * returns a new metadata instance and leaves the original instance unchanged. Implementors are strongly advised to obey
18   * this contract.
19   * 
20   * @author Benjamin Bentmann
21   */
22  public interface Metadata
23  {
24  
25      /**
26       * The nature of the metadata.
27       */
28      enum Nature
29      {
30          /**
31           * The metadata refers to release artifacts only.
32           */
33          RELEASE,
34  
35          /**
36           * The metadata refers to snapshot artifacts only.
37           */
38          SNAPSHOT,
39  
40          /**
41           * The metadata refers to either release or snapshot artifacts.
42           */
43          RELEASE_OR_SNAPSHOT
44      }
45  
46      /**
47       * Gets the group identifier of this metadata.
48       * 
49       * @return The group identifier or an empty string if the metadata applies to the entire repository, never {@code
50       *         null}.
51       */
52      String getGroupId();
53  
54      /**
55       * Gets the artifact identifier of this metadata.
56       * 
57       * @return The artifact identifier or an empty string if the metadata applies to the groupId level only, never
58       *         {@code null}.
59       */
60      String getArtifactId();
61  
62      /**
63       * Gets the version of this metadata.
64       * 
65       * @return The version or an empty string if the metadata applies to the groupId:artifactId level only, never
66       *         {@code null}.
67       */
68      String getVersion();
69  
70      /**
71       * Gets the type of the metadata, e.g. "maven-metadata.xml".
72       * 
73       * @return The type of the metadata, never {@code null}.
74       */
75      String getType();
76  
77      /**
78       * Gets the nature of this metadata. The nature indicates to what artifact versions the metadata refers.
79       * 
80       * @return The nature, never {@code null}.
81       */
82      Nature getNature();
83  
84      /**
85       * Gets the file of this metadata. Note that only resolved metadata has a file associated with it.
86       * 
87       * @return The file or {@code null} if none.
88       */
89      File getFile();
90  
91      /**
92       * Sets the file of the metadata.
93       * 
94       * @param file The file of the metadata, may be {@code null}
95       * @return The new metadata, never {@code null}.
96       */
97      Metadata setFile( File file );
98  
99  }