View Javadoc

1   /***
2    * Copyright 2007 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *         http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * For more information visit
11   *         http://72miles.com and
12   *         http://architecturerules.googlecode.com/svn/docs/index.html
13   */
14  
15  package com.seventytwomiles.architecturerules.configuration;
16  
17  
18  import com.seventytwomiles.architecturerules.domain.Rule;
19  import com.seventytwomiles.architecturerules.domain.SourceDirectory;
20  import org.apache.commons.logging.Log;
21  import org.apache.commons.logging.LogFactory;
22  
23  import java.util.Collection;
24  import java.util.Collections;
25  
26  
27  /***
28   * <p>An UnmodifiableConfiguration is a <code>Configuration</code> instance
29   * whose setters and collections are unavailable or unmodifiable.</p>
30   *
31   * @author mikenereson
32   */
33  public final class UnmodifiableConfiguration extends Configuration {
34  
35  
36      protected static final Log log = LogFactory.getLog(
37              UnmodifiableConfiguration.class);
38  
39  
40      /***
41       * <p>Instantiates a new unmodifiable configuration class.</p>
42       *
43       * @param configuration Configuration to offer as unmodifiable
44       */
45      public UnmodifiableConfiguration(final Configuration configuration) {
46  
47          super.getRules().addAll(configuration.getRules());
48          super.getSources().addAll(configuration.getSources());
49  
50          super.setDoCyclicDependencyTest(
51                  configuration.shouldDoCyclicDependencyTest());
52  
53          super.setThrowExceptionWhenNoPackages(
54                  configuration.shouldThrowExceptionWhenNoPackages());
55      }
56  
57  
58      /***
59       * <p>Getter for property {@link #rules}.</p>
60       *
61       * @return Value for property <tt>rules</tt>.
62       */
63      @Override
64      public Collection<Rule> getRules() {
65          return Collections.unmodifiableCollection(super.getRules());
66      }
67  
68  
69      /***
70       * <p>Getter for property {@link #sources}.</p>
71       *
72       * @return Value for property <tt>sources</tt>.
73       */
74      @Override
75      public Collection<SourceDirectory> getSources() {
76          return Collections.unmodifiableCollection(super.getSources());
77      }
78  
79  
80      /***
81       * <p>Setter for property {@link #doCyclicDependencyTest}.</p>
82       *
83       * @param doCyclicDependencyTest Value to set for property <tt>doCyclicDependencyTest</tt>.
84       */
85      @Override
86      public UnmodifiableConfiguration setDoCyclicDependencyTest(
87              final boolean doCyclicDependencyTest) {
88  
89          throw new UnsupportedOperationException("");
90      }
91  
92  
93      /***
94       * <p>Setter for property {@link #throwExceptionWhenNoPackages}.</p>
95       *
96       * @param throwExceptionWhenNoPackages Value to set for property
97       *                                     <tt>throwExceptionWhenNoPackages</tt>.
98       */
99      @Override
100     public UnmodifiableConfiguration setThrowExceptionWhenNoPackages(
101             final boolean throwExceptionWhenNoPackages) {
102 
103         throw new UnsupportedOperationException("");
104     }
105 }