01: /*****************************************************************************
02: * Copyright (C) PicoContainer Organization. All rights reserved. *
03: * ------------------------------------------------------------------------- *
04: * The software in this package is published under the terms of the BSD *
05: * style license a copy of which has been included with this distribution in *
06: * the LICENSE.txt file. *
07: *****************************************************************************/package org.picocontainer.gems.constraints;
08:
09: import org.picocontainer.ComponentAdapter;
10: import org.picocontainer.PicoVisitor;
11: import org.picocontainer.parameters.CollectionComponentParameter;
12:
13: /**
14: * Constraint that collects/aggregates dependencies to as many components
15: * that satisfy the given constraint.
16: *
17: * @author Nick Sieger
18: * @author Jörg Schaible
19: */
20: public final class CollectionConstraint extends
21: CollectionComponentParameter implements Constraint {
22: protected final Constraint constraint;
23:
24: public CollectionConstraint(Constraint constraint) {
25: this (constraint, false);
26: }
27:
28: public CollectionConstraint(Constraint constraint,
29: boolean emptyCollection) {
30: super (Object.class, emptyCollection);
31: this .constraint = constraint;
32: }
33:
34: public boolean evaluate(ComponentAdapter adapter) {
35: return constraint.evaluate(adapter);
36: }
37:
38: public void accept(PicoVisitor visitor) {
39: super.accept(visitor);
40: constraint.accept(visitor);
41: }
42: }
|