01: /*******************************************************************************
02: * Portions created by Sebastian Thomschke are copyright (c) 2005-2007 Sebastian
03: * Thomschke.
04: *
05: * All Rights Reserved. This program and the accompanying materials
06: * are made available under the terms of the Eclipse Public License v1.0
07: * which accompanies this distribution, and is available at
08: * http://www.eclipse.org/legal/epl-v10.html
09: *
10: * Contributors:
11: * Sebastian Thomschke - initial implementation.
12: *******************************************************************************/package net.sf.oval.configuration.pojo;
13:
14: import java.io.Serializable;
15: import java.util.Set;
16:
17: import net.sf.oval.configuration.Configurer;
18: import net.sf.oval.configuration.pojo.elements.ClassConfiguration;
19: import net.sf.oval.configuration.pojo.elements.ConstraintSetConfiguration;
20: import net.sf.oval.exception.OValException;
21:
22: /**
23: * @author Sebastian Thomschke
24: */
25: public class POJOConfigurer implements Configurer, Serializable {
26: private static final long serialVersionUID = 1L;
27:
28: protected Set<ClassConfiguration> classConfigurations;
29: protected Set<ConstraintSetConfiguration> constraintSetConfigurations;
30:
31: public ClassConfiguration getClassConfiguration(final Class<?> clazz) {
32: if (classConfigurations != null) {
33: for (final ClassConfiguration classConfig : classConfigurations) {
34: if (classConfig.type == clazz)
35: return classConfig;
36: }
37: }
38: return null;
39: }
40:
41: /**
42: * @return the classConfigurations
43: */
44: public Set<ClassConfiguration> getClassConfigurations() {
45: return classConfigurations;
46: }
47:
48: public ConstraintSetConfiguration getConstraintSetConfiguration(
49: final String constraintSetId) throws OValException {
50: if (constraintSetConfigurations == null)
51: return null;
52:
53: for (final ConstraintSetConfiguration csc : constraintSetConfigurations) {
54: if (constraintSetId.equals(csc.id))
55: return csc;
56: }
57: return null;
58: }
59:
60: /**
61: * @return the constraintSetConfigurations
62: */
63: public Set<ConstraintSetConfiguration> getConstraintSetConfigurations() {
64: return constraintSetConfigurations;
65: }
66:
67: /**
68: * @param classConfigurations the classConfigurations to set
69: */
70: public void setClassConfigurations(
71: final Set<ClassConfiguration> classConfigurations) {
72: this .classConfigurations = classConfigurations;
73: }
74:
75: /**
76: * @param constraintSetConfigurations the constraintSetConfigurations to set
77: */
78: public void setConstraintSetConfigurations(
79: final Set<ConstraintSetConfiguration> constraintSetConfigurations) {
80: this.constraintSetConfigurations = constraintSetConfigurations;
81: }
82: }
|