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