Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
PartBean |
|
| 1.0;1 |
1 | /* | |
2 | * Copyright (c) 2009, Swiss Federal Department of Defence Civil Protection and Sport | |
3 | * (http://www.vbs.admin.ch) | |
4 | * Copyright (c) 2009, Ergon Informatik AG (http://www.ergon.ch) | |
5 | * All rights reserved. | |
6 | * | |
7 | * Licensed under the Open Permis License which accompanies this distribution, | |
8 | * and is available at http://www.openpermis.org/BSDlicenceKent.txt | |
9 | */ | |
10 | package org.openpermis.policy.bean; | |
11 | ||
12 | import java.beans.PropertyChangeListener; | |
13 | ||
14 | import org.openpermis.policy.Part; | |
15 | ||
16 | ||
17 | /** | |
18 | * Mutable part that has JavaBean property and serial number support. | |
19 | * @since 0.1.0 | |
20 | */ | |
21 | public interface PartBean | |
22 | extends Part | |
23 | { | |
24 | ||
25 | //---- Methods | |
26 | ||
27 | /** | |
28 | * Returns the serial number of this part. | |
29 | * @return the serial number of this part. | |
30 | * @since 0.1.0 | |
31 | */ | |
32 | public SerialNumber getSerialNumber (); | |
33 | ||
34 | /** | |
35 | * Returns the primary part bean interface class that this part implements. | |
36 | * @return the primary part bean interface class that this part implements. | |
37 | * @since 0.3.0 | |
38 | */ | |
39 | public Class<? extends PartBean> getPartBeanType (); | |
40 | ||
41 | /** | |
42 | * Compares the serial number of this part to the one of the specified part. | |
43 | * @param part the part bean whose serial number to compare to this one. | |
44 | * @return {@code true} if the specified part has the same serial number as this one, | |
45 | * {@code false} otherwise. | |
46 | * @since 0.1.0 | |
47 | */ | |
48 | public boolean equalSerialNumber (PartBean part); | |
49 | ||
50 | /** | |
51 | * Returns the part bean corresponding to the specified serial number. | |
52 | * <p>If the part bean contains other part beans, it searches its child beans recursively. | |
53 | * @param serialNumber the {@link SerialNumber} of the part bean to return. | |
54 | * @return the matching {@link PartBean} or <code>null</code> if no | |
55 | * matching part bean is found. | |
56 | * @since 0.1.0 | |
57 | */ | |
58 | public PartBean findBySerialNumber (SerialNumber serialNumber); | |
59 | ||
60 | /** | |
61 | * Returns the serial number string representation of this class. | |
62 | * <p>The simplified string representation only consists only of the | |
63 | * {@link Class#getSimpleName() simple implementation class name} of this part followed | |
64 | * by the serial number in square brackets.</p> | |
65 | * @return the serial number string representation of this class. | |
66 | * @since 0.1.0 | |
67 | */ | |
68 | public String toShortString (); | |
69 | ||
70 | //---- JavaBean | |
71 | ||
72 | /** | |
73 | * Adds a property change listener to this part bean. | |
74 | * <p>The change listener will be notified whenever this part or a sub part that is contained | |
75 | * in this part changes.</p> | |
76 | * <p>Changes of parts contained are forwarded with a property change event that is using | |
77 | * {@code null} as old and new value.</p> | |
78 | * <p>The same {@code listener} object may be added more than once, and will be called as many | |
79 | * times as it is added.</p> | |
80 | * <p>If the {@code listener} is {@code null}, no action is taken.</p> | |
81 | * @param listener the listener to be added, may be {@code null}. | |
82 | * @since 0.1.0 | |
83 | */ | |
84 | public void addPropertyChangeListener (PropertyChangeListener listener); | |
85 | ||
86 | /** | |
87 | * Removes a property change listener from this part bean. | |
88 | * <p>If the same {@code listener} was added more than once, it will be notified one less | |
89 | * time after being removed.</p> | |
90 | * <p>If the {@code listener} is {@code null}, or was never added, no action is taken.</p> | |
91 | * @param listener the listener to be removed, may be {@code null}. | |
92 | * @since 0.1.0 | |
93 | */ | |
94 | public void removePropertyChangeListener (PropertyChangeListener listener); | |
95 | ||
96 | } |