View Javadoc

1   /*
2      Copyright 2008 Ramon Servadei
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     Unless required by applicable law or agreed to in writing, software
11     distributed under the License is distributed on an "AS IS" BASIS,
12     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13     See the License for the specific language governing permissions and
14     limitations under the License.
15   */
16  package fulmine.event.subscription;
17  
18  import fulmine.IAddressable;
19  import fulmine.IDestroyable;
20  import fulmine.event.IEventSource;
21  
22  /**
23   * Represents the parameters of a subscription for an {@link IEventSource}. This
24   * extends the {@link IAddressable} interface and encapsulates the type, domain
25   * and identity attributes of event sources that would match.
26   * <p>
27   * The wildcards
28   * <ul>
29   * <li>{@link ISubscription#WILDCARD_ID_REGEX}
30   * <li>{@link ISubscription#WILDCARD_TYPE}
31   * <li>{@link ISubscription#WILDCARD_DOMAIN}
32   * </ul>
33   * can be used for the relevant attribute of the subscription.
34   * <p>
35   * Instances are compared to each other using their attribute values; a wildcard
36   * attribute will only match a wildcard attribute for comparison.
37   * 
38   * @see ISubscription
39   * @author Ramon Servadei
40   */
41  public interface ISubscriptionParameters extends IDestroyable, IAddressable
42  {
43      /**
44       * Determine if the {@link IAddressable} attributes of this parameters
45       * instance would include those of another. For this instance to include the
46       * other, each attribute of this instance must be an exact match or a more
47       * generalised match of corresponding attribute in the other.
48       * <p>
49       * For example, assuming the type and domain are equal, if this instance has
50       * the identity regular expression "foo.*" and the other instance has the
51       * identity "foo bar", then this instance effectively includes the other (it
52       * is more generalised). However, it would not include the other if the
53       * other instance has an identity regular expression ".*" as this is now
54       * more generalised than this instance.
55       * 
56       * @param other
57       *            the other {@link IAddressable} instance to compare with this
58       * @return <code>true</code> if the attributes of this instance include
59       *         those of the other
60       */
61      boolean includes(IAddressable other);
62  }