1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 */ 19 package org.eclipse.aether.metadata; 20 21 import java.io.File; 22 import java.util.Map; 23 24 /** 25 * A piece of repository metadata, e.g. an index of available versions. In contrast to an artifact, which usually exists 26 * in only one repository, metadata usually exists in multiple repositories and each repository contains a different 27 * copy of the metadata. <em>Note:</em> Metadata instances are supposed to be immutable, e.g. any exposed mutator method 28 * returns a new metadata instance and leaves the original instance unchanged. Implementors are strongly advised to obey 29 * this contract. <em>Note:</em> Implementors are strongly advised to inherit from {@link AbstractMetadata} instead of 30 * directly implementing this interface. 31 * 32 * @noimplement This interface is not intended to be implemented by clients. 33 * @noextend This interface is not intended to be extended by clients. 34 */ 35 public interface Metadata { 36 37 /** 38 * The nature of the metadata. 39 */ 40 enum Nature { 41 /** 42 * The metadata refers to release artifacts only. 43 */ 44 RELEASE, 45 46 /** 47 * The metadata refers to snapshot artifacts only. 48 */ 49 SNAPSHOT, 50 51 /** 52 * The metadata refers to either release or snapshot artifacts. 53 */ 54 RELEASE_OR_SNAPSHOT 55 } 56 57 /** 58 * Gets the group identifier of this metadata. 59 * 60 * @return The group identifier or an empty string if the metadata applies to the entire repository, never 61 * {@code null}. 62 */ 63 String getGroupId(); 64 65 /** 66 * Gets the artifact identifier of this metadata. 67 * 68 * @return The artifact identifier or an empty string if the metadata applies to the groupId level only, never 69 * {@code null}. 70 */ 71 String getArtifactId(); 72 73 /** 74 * Gets the version of this metadata. 75 * 76 * @return The version or an empty string if the metadata applies to the groupId:artifactId level only, never 77 * {@code null}. 78 */ 79 String getVersion(); 80 81 /** 82 * Gets the type of the metadata, e.g. "maven-metadata.xml". 83 * 84 * @return The type of the metadata, never {@code null}. 85 */ 86 String getType(); 87 88 /** 89 * Gets the nature of this metadata. The nature indicates to what artifact versions the metadata refers. 90 * 91 * @return The nature, never {@code null}. 92 */ 93 Nature getNature(); 94 95 /** 96 * Gets the file of this metadata. Note that only resolved metadata has a file associated with it. 97 * 98 * @return The file or {@code null} if none. 99 */ 100 File getFile(); 101 102 /** 103 * Sets the file of the metadata. 104 * 105 * @param file The file of the metadata, may be {@code null} 106 * @return The new metadata, never {@code null}. 107 */ 108 Metadata setFile(File file); 109 110 /** 111 * Gets the specified property. 112 * 113 * @param key The name of the property, must not be {@code null}. 114 * @param defaultValue The default value to return in case the property is not set, may be {@code null}. 115 * @return The requested property value or {@code null} if the property is not set and no default value was 116 * provided. 117 */ 118 String getProperty(String key, String defaultValue); 119 120 /** 121 * Gets the properties of this metadata. 122 * 123 * @return The (read-only) properties, never {@code null}. 124 */ 125 Map<String, String> getProperties(); 126 127 /** 128 * Sets the properties for the metadata. 129 * 130 * @param properties The properties for the metadata, may be {@code null}. 131 * @return The new metadata, never {@code null}. 132 */ 133 Metadata setProperties(Map<String, String> properties); 134 }