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.guard;
13:
14: import java.util.Arrays;
15: import java.util.List;
16:
17: import net.sf.oval.ConstraintViolation;
18: import net.sf.oval.exception.ConstraintsViolatedException;
19: import net.sf.oval.internal.CollectionFactoryHolder;
20:
21: /**
22: * @author Sebastian Thomschke
23: */
24: public class ConstraintsViolatedAdapter implements
25: ConstraintsViolatedListener {
26: private final List<ConstraintsViolatedException> violationExceptions = CollectionFactoryHolder
27: .getFactory().createList(8);
28: private final List<ConstraintViolation> violations = CollectionFactoryHolder
29: .getFactory().createList(8);
30:
31: public void clear() {
32: violationExceptions.clear();
33: violations.clear();
34: }
35:
36: /**
37: * @return Returns the constraint violation exceptions.
38: */
39: public List<ConstraintsViolatedException> getConstraintsViolatedExceptions() {
40: return violationExceptions;
41: }
42:
43: /**
44: * @return Returns the constraint violations.
45: */
46: public List<ConstraintViolation> getConstraintViolations() {
47: return violations;
48: }
49:
50: public void onConstraintsViolatedException(
51: final ConstraintsViolatedException exception) {
52: violationExceptions.add(exception);
53: violations.addAll(Arrays.asList(exception
54: .getConstraintViolations()));
55: }
56: }
|