Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
Part |
|
| 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; | |
11 | ||
12 | import java.io.Serializable; | |
13 | ||
14 | /** | |
15 | * Describes a part of a policy. | |
16 | * <p>All complex objects in a policy implement the part interface.</p> | |
17 | * @since 0.1.0 | |
18 | */ | |
19 | public interface Part | |
20 | extends Serializable | |
21 | { | |
22 | ||
23 | //---- Methods | |
24 | ||
25 | /** | |
26 | * Check if this part and all parts contained are valid. | |
27 | * <p>Instead of enforcing that a part is valid at all times a part may be invalid | |
28 | * (for example while loading a policy from a file or while editing a part). Use this | |
29 | * method to assert that a part is valid.</p> | |
30 | * @note Complex parts should also check the validity of parts included. | |
31 | * @param reporter optional callback where violiations are reported, may be {@code null} | |
32 | * if the caller is not interested in details about the violations. | |
33 | * @return {@code true} if the part and all parts contained are valid, | |
34 | * {@code false} if this part or at least one part contained are invalid. | |
35 | * @since 0.1.0 | |
36 | */ | |
37 | public boolean isValid (PartProblemReporter reporter); | |
38 | ||
39 | //---- Object | |
40 | ||
41 | /** | |
42 | * Check if this policy part is equivalent to the one specified. | |
43 | * <p>A part is considered equivalent to this part if it's state is equivalent to the | |
44 | * state of this part and all parts contained are equivalent to the parts contained in | |
45 | * this policy part.</p> | |
46 | * @param obj the policy part to compare this policy part to. | |
47 | * @see #hashCode() | |
48 | * @since 0.1.0 | |
49 | */ | |
50 | public boolean equals (Object obj); | |
51 | ||
52 | /** | |
53 | * Returns the hash code of this policy part. | |
54 | * <p>In addition to the general contract for {@link Object#hashCode()} the hash code | |
55 | * of a policy part should not make use of the default object hash code. Instead the | |
56 | * hash code of a policy part should only be calculated according to the contents of | |
57 | * the policy part in such a way that different instances of a policy part with the | |
58 | * same content return the same hash code.</p> | |
59 | * @return the hash code of this policy part. | |
60 | * @see #equals(Object) | |
61 | * @since 0.1.0 | |
62 | */ | |
63 | public int hashCode (); | |
64 | ||
65 | /** | |
66 | * Returns a string representation of this policy part. | |
67 | * <p>The string representation is purely informational and provides summary of the part | |
68 | * in the following form: {@code PartName [serial=value, ...]}. The string representation | |
69 | * starts with the {@link Class#getSimpleName() simple implementation class name} and is | |
70 | * followed by its details in square brackets.</p> | |
71 | * @return the string representation of this policy part. | |
72 | * @see Object#toString() | |
73 | * @since 0.1.0 | |
74 | */ | |
75 | public String toString (); | |
76 | ||
77 | } |