1 /* |
|
2 * CDDL HEADER START |
|
3 * |
|
4 * The contents of this file are subject to the terms of the |
|
5 * Common Development and Distribution License (the "License"). |
|
6 * You may not use this file except in compliance with the License. |
|
7 * |
|
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
|
9 * or http://www.opensolaris.org/os/licensing. |
|
10 * See the License for the specific language governing permissions |
|
11 * and limitations under the License. |
|
12 * |
|
13 * When distributing Covered Code, include this CDDL HEADER in each |
|
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
|
15 * If applicable, add the following below this CDDL HEADER, with the |
|
16 * fields enclosed by brackets "[]" replaced with your own identifying |
|
17 * information: Portions Copyright [yyyy] [name of copyright owner] |
|
18 * |
|
19 * CDDL HEADER END |
|
20 */ |
|
21 |
|
22 /* |
|
23 * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. |
|
24 */ |
|
25 |
|
26 package com.oracle.solaris.vp.util.misc.property; |
|
27 |
|
28 import java.beans.PropertyChangeListener; |
|
29 import com.oracle.solaris.vp.util.misc.Changeable; |
|
30 import com.oracle.solaris.vp.util.misc.converter.DualConverter; |
|
31 |
|
32 public interface MutableProperty<T> extends Changeable { |
|
33 /** |
|
34 * Adds a {@code PropertyChangeListener} to listen for changes in the {@link |
|
35 * #getValue current} or {@link #getSavedValue saved} value of this |
|
36 * property. |
|
37 */ |
|
38 void addPropertyChangeListener(PropertyChangeListener listener); |
|
39 |
|
40 /** |
|
41 * Removes a {@code PropertyChangeListener} from notifications of changes in |
|
42 * the {@link #getValue value} of this property. |
|
43 */ |
|
44 boolean removePropertyChangeListener(PropertyChangeListener listener); |
|
45 |
|
46 /** |
|
47 * Gets a {@link DualConverter} to convert the value of this {@code |
|
48 * MutableProperty} to and from a {@code String}. |
|
49 * |
|
50 * @return a {@link DualConverter}, or {@code null} if the value of |
|
51 * this {@code MutableProperty} cannot be converted to and from |
|
52 * a {@code String}. |
|
53 */ |
|
54 DualConverter<String, T> getConverter(); |
|
55 |
|
56 /** |
|
57 * Gets the name of this property. |
|
58 * |
|
59 * @return a {@code String}, or {@code null} if this property has no |
|
60 * name |
|
61 */ |
|
62 String getPropertyName(); |
|
63 |
|
64 /** |
|
65 * Gets the wrapped model's saved value. |
|
66 */ |
|
67 T getSavedValue(); |
|
68 |
|
69 /** |
|
70 * Gets the wrapped model's current value. |
|
71 */ |
|
72 T getValue(); |
|
73 |
|
74 /** |
|
75 * Sets the wrapped model's saved value. |
|
76 */ |
|
77 void setSavedValue(T saved); |
|
78 |
|
79 /** |
|
80 * Sets the wrapped model's current value. |
|
81 */ |
|
82 void setValue(T t); |
|
83 |
|
84 /** |
|
85 * Sets the given value as the {@link #getSavedValue saved value}, then |
|
86 * {@link #reset reset}s this {@code MutableProperty} if the current and |
|
87 * saved values hadn't differed prior to this update. |
|
88 * |
|
89 * @param value |
|
90 * the new saved value |
|
91 * |
|
92 * @param force |
|
93 * if {@code true}, {@link #reset reset}s unconditionally after |
|
94 * setting the new saved value |
|
95 */ |
|
96 void update(T value, boolean force); |
|
97 } |
|