KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > picocontainer > gems > constraints > CollectionConstraint


1 /*****************************************************************************
2  * Copyright (C) PicoContainer Organization. All rights reserved. *
3  * ------------------------------------------------------------------------- *
4  * The software in this package is published under the terms of the BSD *
5  * style license a copy of which has been included with this distribution in *
6  * the LICENSE.txt file. *
7  *****************************************************************************/

8
9 package org.picocontainer.gems.constraints;
10
11 import org.picocontainer.ComponentAdapter;
12 import org.picocontainer.PicoVisitor;
13 import org.picocontainer.defaults.CollectionComponentParameter;
14
15 /**
16  * Constraint that collects/aggregates dependencies to as many components
17  * that satisfy the given constraint.
18  *
19  * @author Nick Sieger
20  * @author Jörg Schaible
21  * @version 1.1
22  */

23 public class CollectionConstraint extends CollectionComponentParameter implements Constraint {
24     protected Constraint constraint;
25
26     public CollectionConstraint(Constraint constraint) {
27         this(constraint, false);
28     }
29
30     public CollectionConstraint(Constraint constraint, boolean emptyCollection) {
31         super(Object JavaDoc.class, emptyCollection);
32         this.constraint = constraint;
33     }
34
35     public boolean evaluate(ComponentAdapter adapter) {
36         return constraint.evaluate(adapter);
37     }
38
39     public void accept(PicoVisitor visitor) {
40         super.accept(visitor);
41         constraint.accept(visitor);
42     }
43 }
44
Popular Tags