View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      https://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  
18  package org.apache.commons.beanutils2.priv;
19  
20  /**
21   * Bean that has a private constructor that exposes properties via various mechanisms (based on property name):
22   * <ul>
23   * <li><strong>foo</strong> - Via direct public method
24   * <li><strong>bar</strong> - Via directly implemented interface
25   * <li><strong>baz</strong> - Via indirectly implemented interface
26   * </ul>
27   */
28  class PrivateBean implements PrivateDirect {
29  
30      /**
31       * A directly implemented property.
32       */
33      private final String foo = "This is foo";
34  
35      /**
36       * A property accessible via a directly implemented interface.
37       */
38      private final String bar = "This is bar";
39  
40      /**
41       * A property accessible via an indirectly implemented interface.
42       */
43      private final String baz = "This is baz";
44  
45      /**
46       * Package private constructor - can only use factory method to create beans.
47       */
48      PrivateBean() {
49  
50      }
51  
52      @Override
53      public String getBar() {
54  
55          return this.bar;
56  
57      }
58  
59      @Override
60      public String getBaz() {
61  
62          return this.baz;
63  
64      }
65  
66      public String getFoo() {
67  
68          return this.foo;
69  
70      }
71  
72      /**
73       * A method accessible via a directly implemented interface.
74       */
75      @Override
76      public String methodBar(final String in) {
77  
78          return in;
79  
80      }
81  
82      /**
83       * A method accessible via an indirectly implemented interface.
84       */
85      @Override
86      public String methodBaz(final String in) {
87  
88          return in;
89  
90      }
91  
92  }