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.configuration;
20
21 /**
22 * A request to configure a bean from some configuration in the POM or similar.
23 *
24 * @author Benjamin Bentmann
25 */
26 public interface BeanConfigurationRequest {
27
28 /**
29 * Gets the bean to configure. Eventually, a valid request must have a bean set.
30 *
31 * @return The bean to configure, or {@code null} if none.
32 */
33 Object getBean();
34
35 /**
36 * Sets the bean to configure. Eventually, a valid request must have a bean set.
37 *
38 * @param bean The bean to configure, may be {@code null}.
39 * @return This request for chaining, never {@code null}.
40 */
41 BeanConfigurationRequest setBean(Object bean);
42
43 /**
44 * Gets the configuration to unmarshal into the bean.
45 *
46 * @return The configuration to unmarshal into the bean or {@code null} if none.
47 */
48 Object getConfiguration();
49
50 /**
51 * Sets the configuration to unmarshal into the bean. The configuration should be taken from
52 * {@link org.apache.maven.model.ConfigurationContainer#getConfiguration()} or a similar source.
53 * Fully equivalent to {@code setConfiguration(configuration, null)}.
54 *
55 * @param configuration The configuration to unmarshal, may be {@code null}.
56 * @return This request for chaining, never {@code null}.
57 */
58 BeanConfigurationRequest setConfiguration(Object configuration);
59
60 /**
61 * Sets the configuration to unmarshal into the bean. The configuration should be taken from
62 * {@link org.apache.maven.model.ConfigurationContainer#getConfiguration()} or a similar source.
63 * If {@code element} is not {@code null}, child configuration element with the specified name will
64 * be unmarshaled.
65 *
66 * @param configuration The configuration to unmarshal, may be {@code null}.
67 * @param element Configuration element name to unmarshal or {@code null} to unmarshal entire configuration.
68 * @return This request for chaining, never {@code null}.
69 */
70 BeanConfigurationRequest setConfiguration(Object configuration, String element);
71
72 /**
73 * Returns configuration element name or {@code null}.
74 *
75 * @see #setConfiguration(Object, String)
76 *
77 * @return Configuration element name or {@code null}
78 */
79 String getConfigurationElement();
80
81 /**
82 * Gets the class loader from which to load any types referenced by the configuration. If unset, the class loader of
83 * the bean class will be used.
84 *
85 * @return The class loader to load referenced types from or {@code null} if unset.
86 */
87 ClassLoader getClassLoader();
88
89 /**
90 * Sets the class loader from which to load any types referenced by the configuration. If unset, the class loader of
91 * the bean class will be used.
92 *
93 * @param classLoader The class loader to load referenced types from, may be {@code null}.
94 * @return This request for chaining, never {@code null}.
95 */
96 BeanConfigurationRequest setClassLoader(ClassLoader classLoader);
97
98 /**
99 * Gets the optional preprocessor for configuration values.
100 *
101 * @return The preprocessor for configuration values or {@code null} if none.
102 */
103 BeanConfigurationValuePreprocessor getValuePreprocessor();
104
105 /**
106 * Sets the optional preprocessor for configuration values.
107 *
108 * @param valuePreprocessor The preprocessor for configuration values, may be {@code null} if unneeded.
109 * @return This request for chaining, never {@code null}.
110 */
111 BeanConfigurationRequest setValuePreprocessor(BeanConfigurationValuePreprocessor valuePreprocessor);
112
113 /**
114 * Gets the optional path translator for configuration values unmarshalled to files.
115 *
116 * @return The path translator for files or {@code null} if none.
117 */
118 BeanConfigurationPathTranslator getPathTranslator();
119
120 /**
121 * Sets the optional path translator for configuration values unmarshalled to files.
122 *
123 * @param pathTranslator The path translator for files, may be {@code null} if unneeded.
124 * @return This request for chaining, never {@code null}.
125 */
126 BeanConfigurationRequest setPathTranslator(BeanConfigurationPathTranslator pathTranslator);
127 }