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.apache.maven.model.building;
20
21 import org.apache.maven.api.model.DependencyManagement;
22 import org.apache.maven.api.model.Model;
23
24 /**
25 * Describes a tag used by the model builder to access a {@link ModelCache}. This interface basically aggregates a name
26 * and a class to provide some type safety when working with the otherwise untyped cache.
27 *
28 * @param <T> The type of data associated with the tag.
29 */
30 interface ModelCacheTag<T> {
31
32 /**
33 * Gets the name of the tag.
34 *
35 * @return The name of the tag, must not be {@code null}.
36 */
37 String getName();
38
39 /**
40 * Gets the type of data associated with this tag.
41 *
42 * @return The type of data, must not be {@code null}.
43 */
44 Class<T> getType();
45
46 /**
47 * The tag used for the raw model without profile activation
48 */
49 ModelCacheTag<ModelData> RAW = new ModelCacheTag<ModelData>() {
50
51 @Override
52 public String getName() {
53 return "raw";
54 }
55
56 @Override
57 public Class<ModelData> getType() {
58 return ModelData.class;
59 }
60 };
61
62 /**
63 * The tag used to denote an effective dependency management section from an imported model.
64 */
65 ModelCacheTag<DependencyManagement> IMPORT = new ModelCacheTag<DependencyManagement>() {
66
67 @Override
68 public String getName() {
69 return "import";
70 }
71
72 @Override
73 public Class<DependencyManagement> getType() {
74 return DependencyManagement.class;
75 }
76 };
77
78 /**
79 * The tag used for the file model without profile activation
80 * @since 4.0.0
81 */
82 ModelCacheTag<Model> FILE = new ModelCacheTag<Model>() {
83 @Override
84 public String getName() {
85 return "file";
86 }
87
88 @Override
89 public Class<Model> getType() {
90 return Model.class;
91 }
92 };
93 }