View Javadoc

1   package org.apache.maven.configuration;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  /**
23   * A request to configure a bean from some configuration in the POM or similar.
24   * 
25   * @author Benjamin Bentmann
26   */
27  public interface BeanConfigurationRequest
28  {
29  
30      /**
31       * Gets the bean to configure. Eventually, a valid request must have a bean set.
32       * 
33       * @return The bean to configure, or {@code null} if none.
34       */
35      Object getBean();
36  
37      /**
38       * Sets the bean to configure. Eventually, a valid request must have a bean set.
39       * 
40       * @param bean The bean to configure, may be {@code null}.
41       * @return This request for chaining, never {@code null}.
42       */
43      BeanConfigurationRequest setBean( Object bean );
44  
45      /**
46       * Gets the configuration to unmarshal into the bean.
47       * 
48       * @return The configuration to unmarshal into the bean or {@code null} if none.
49       */
50      Object getConfiguration();
51  
52      /**
53       * Sets the configuration to unmarshal into the bean. The configuration should be taken from
54       * {@link org.apache.maven.model.ConfigurationContainer#getConfiguration()} or a similar source.
55       * Fully equivalent to {@code setConfiguration(configuration, null)}.
56       * 
57       * @param configuration The configuration to unmarshal, may be {@code null}.
58       * @return This request for chaining, never {@code null}.
59       */
60      BeanConfigurationRequest setConfiguration( Object configuration );
61  
62      /**
63       * Sets the configuration to unmarshal into the bean. The configuration should be taken from
64       * {@link org.apache.maven.model.ConfigurationContainer#getConfiguration()} or a similar source.
65       * If {@code element} is not {@code null}, child configuration element with the specified name will 
66       * be unmarshaled.
67       * 
68       * @param configuration The configuration to unmarshal, may be {@code null}.
69       * @param element Configuration element name to unmarshal or {@code null} to unmarshal entire configuration.
70       * @return This request for chaining, never {@code null}.
71       */
72      BeanConfigurationRequest setConfiguration( Object configuration, String element );
73  
74      /**
75       * Returns configuration element name or {@code null}. 
76       * 
77       * @see #setConfiguration(Object, String)
78       * 
79       * @return Configuration element name or {@code null}
80       */
81      String getConfigurationElement();
82  
83      /**
84       * Gets the class loader from which to load any types referenced by the configuration. If unset, the class loader of
85       * the bean class will be used.
86       * 
87       * @return The class loader to load referenced types from or {@code null} if unset.
88       */
89      ClassLoader getClassLoader();
90  
91      /**
92       * Sets the class loader from which to load any types referenced by the configuration. If unset, the class loader of
93       * the bean class will be used.
94       * 
95       * @param classLoader The class loader to load referenced types from, may be {@code null}.
96       * @return This request for chaining, never {@code null}.
97       */
98      BeanConfigurationRequest setClassLoader( ClassLoader classLoader );
99  
100     /**
101      * Gets the optional preprocessor for configuration values.
102      * 
103      * @return The preprocessor for configuration values or {@code null} if none.
104      */
105     BeanConfigurationValuePreprocessor getValuePreprocessor();
106 
107     /**
108      * Sets the optional preprocessor for configuration values.
109      * 
110      * @param valuePreprocessor The preprocessor for configuration values, may be {@code null} if unneeded.
111      * @return This request for chaining, never {@code null}.
112      */
113     BeanConfigurationRequest setValuePreprocessor( BeanConfigurationValuePreprocessor valuePreprocessor );
114 
115     /**
116      * Gets the optional path translator for configuration values unmarshalled to files.
117      * 
118      * @return The path translator for files or {@code null} if none.
119      */
120     BeanConfigurationPathTranslator getPathTranslator();
121 
122     /**
123      * Sets the optional path translator for configuration values unmarshalled to files.
124      * 
125      * @param pathTranslator The path translator for files, may be {@code null} if unneeded.
126      * @return This request for chaining, never {@code null}.
127      */
128     BeanConfigurationRequest setPathTranslator( BeanConfigurationPathTranslator pathTranslator );
129 
130 }