View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.config.spring.parsers.assembly.configuration;
8   
9   import java.util.Map;
10  
11  /**
12   * Allow initial mutation; first call of reset stores values as reference and allows
13   * further temporary mutation; further calls to reset return to reference.
14   */
15  public class ReusablePropertyConfiguration implements PropertyConfiguration
16  {
17      private PropertyConfiguration reference;
18      private PropertyConfiguration delegate;
19  
20      public ReusablePropertyConfiguration()
21      {
22          this(new SimplePropertyConfiguration());
23      }
24  
25      public ReusablePropertyConfiguration(PropertyConfiguration delegate)
26      {
27          this.delegate = delegate;
28      }
29  
30      public void reset()
31      {
32          if (null == reference)
33          {
34              reference = delegate;
35          }
36          delegate = new TempWrapperPropertyConfiguration(reference);
37      }
38  
39      public void addReference(String propertyName)
40      {
41          delegate.addReference(propertyName);
42      }
43  
44      public void addMapping(String propertyName, Map mappings)
45      {
46          delegate.addMapping(propertyName, mappings);
47      }
48  
49      public void addMapping(String propertyName, String mappings)
50      {
51          delegate.addMapping(propertyName, mappings);
52      }
53  
54      public void addMapping(String propertyName, ValueMap mappings)
55      {
56          delegate.addMapping(propertyName, mappings);
57      }
58  
59      public void addAlias(String alias, String propertyName)
60      {
61          delegate.addAlias(alias, propertyName);
62      }
63  
64      public void addCollection(String propertyName)
65      {
66          delegate.addCollection(propertyName);
67      }
68  
69      public void addIgnored(String propertyName)
70      {
71          delegate.addIgnored(propertyName);
72      }
73  
74      public void removeIgnored(String propertyName)
75      {
76          delegate.removeIgnored(propertyName);
77      }
78  
79      public void setIgnoredDefault(boolean ignoreAll)
80      {
81          delegate.setIgnoredDefault(ignoreAll);
82      }
83  
84      public String getAttributeMapping(String alias)
85      {
86          return delegate.getAttributeMapping(alias);
87      }
88  
89      public String getAttributeAlias(String mapping)
90      {
91          return delegate.getAttributeAlias(mapping);
92      }
93  
94      public boolean isCollection(String propertyName)
95      {
96          return delegate.isCollection(propertyName);
97      }
98  
99      public boolean isIgnored(String propertyName)
100     {
101         return delegate.isIgnored(propertyName);
102     }
103 
104     public boolean isReference(String attributeName)
105     {
106         return delegate.isReference(attributeName);
107     }
108 
109     public SingleProperty getSingleProperty(String propertyName)
110     {
111         return new SinglePropertyWrapper(propertyName, this);
112     }
113 
114     public String translateName(String oldName)
115     {
116         return delegate.translateName(oldName);
117     }
118 
119     public Object translateValue(String name, String value)
120     {
121         return delegate.translateValue(name, value);
122     }
123 
124 }