View Javadoc
1   /*
2    * #%L
3    * settings4j
4    * ===============================================================
5    * Copyright (C) 2008 - 2015 Brabenetz Harald, Austria
6    * ===============================================================
7    * Licensed under the Apache License, Version 2.0 (the "License");
8    * you may not use this file except in compliance with the License.
9    * You may obtain a copy of the License at
10   * 
11   *      http://www.apache.org/licenses/LICENSE-2.0
12   * 
13   * Unless required by applicable law or agreed to in writing, software
14   * distributed under the License is distributed on an "AS IS" BASIS,
15   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   * See the License for the specific language governing permissions and
17   * limitations under the License.
18   * #L%
19   */
20  package org.settings4j.connector;
21  
22  import java.util.ArrayList;
23  import java.util.Collections;
24  import java.util.List;
25  
26  import org.settings4j.Connector;
27  import org.settings4j.ContentResolver;
28  import org.settings4j.ObjectResolver;
29  
30  /**
31   * Basic Connector implementations like getter and Setter of contentResolver, objectResolver.
32   *
33   * @author Harald.Brabenetz
34   *
35   */
36  public abstract class AbstractConnector implements Connector {
37  
38      private String name;
39      private ContentResolver contentResolver;
40      private ObjectResolver objectResolver;
41      private final List<Connector> connectors = Collections.synchronizedList(new ArrayList<Connector>());
42  
43      public List<Connector> getConnectors() {
44          return Collections.unmodifiableList(this.connectors);
45      }
46  
47      @Override
48      public void addConnector(final Connector connector) {
49          this.connectors.add(connector);
50      }
51  
52      protected ContentResolver getContentResolver() {
53          return this.contentResolver;
54      }
55  
56      @Override
57      public void setContentResolver(final ContentResolver contentResolver) {
58          this.contentResolver = contentResolver;
59      }
60  
61      protected ObjectResolver getObjectResolver() {
62          return this.objectResolver;
63      }
64  
65      @Override
66      public void setObjectResolver(final ObjectResolver objectResolver) {
67          this.objectResolver = objectResolver;
68      }
69  
70      @Override
71      public String getName() {
72          return this.name;
73      }
74  
75      @Override
76      public void setName(final String name) {
77          this.name = name;
78      }
79  
80      @Override
81      public void init() {
82          // Overwrite this methode if you want do something after all properties are set.
83          // by default there is nothing to do
84      }
85  
86  }