| 1 | /* |
|---|
| 2 | * This code is copyright (c) 2005 David Owen. All rights not explicitly |
|---|
| 3 | * granted by the author are reserved. |
|---|
| 4 | * |
|---|
| 5 | * Created on Aug 2, 2005. |
|---|
| 6 | */ |
|---|
| 7 | package ws.fugue88.access; |
|---|
| 8 | |
|---|
| 9 | import java.lang.reflect.InvocationTargetException; |
|---|
| 10 | |
|---|
| 11 | /** |
|---|
| 12 | * Provides parameterized bindings to specific references to objects (not |
|---|
| 13 | * necessarily to specific objects). |
|---|
| 14 | * |
|---|
| 15 | * @author dsowen |
|---|
| 16 | */ |
|---|
| 17 | public interface Accessor { |
|---|
| 18 | |
|---|
| 19 | /** |
|---|
| 20 | * Returns the natural type of the reference bound by this accessor. This |
|---|
| 21 | * should: |
|---|
| 22 | * <ul> |
|---|
| 23 | * <li>return the same type for every binding to the reference;</li> |
|---|
| 24 | * <li>return that type independent of the actual type of the referenced |
|---|
| 25 | * object; and,</li> |
|---|
| 26 | * <li>return that type even if the reference is currently |
|---|
| 27 | * <code>null</code> or non-existent.</li> |
|---|
| 28 | * </ul> |
|---|
| 29 | * |
|---|
| 30 | * @return |
|---|
| 31 | */ |
|---|
| 32 | Class getType(); |
|---|
| 33 | |
|---|
| 34 | /** |
|---|
| 35 | * Clears the reference bound by this accessor. For references that may be |
|---|
| 36 | * deleted without losing the ability to set it, it should be deleted (e.g. |
|---|
| 37 | * the key in a map may be removed). |
|---|
| 38 | * |
|---|
| 39 | * @throws InvocationTargetException |
|---|
| 40 | */ |
|---|
| 41 | void clearValue() throws InvocationTargetException; |
|---|
| 42 | |
|---|
| 43 | /** |
|---|
| 44 | * Returns the current object to which the reference refers. If the |
|---|
| 45 | * reference does not exist, <code>null</code> should be returned. |
|---|
| 46 | * |
|---|
| 47 | * @return the current value, or <code>null</code> if no reference |
|---|
| 48 | * @throws InvocationTargetException |
|---|
| 49 | */ |
|---|
| 50 | Object getValue() throws InvocationTargetException; |
|---|
| 51 | |
|---|
| 52 | /** |
|---|
| 53 | * Sets the reference to refer to the given object. If the reference does |
|---|
| 54 | * not exist, it is created. |
|---|
| 55 | * |
|---|
| 56 | * @param value |
|---|
| 57 | * @throws InvocationTargetException |
|---|
| 58 | */ |
|---|
| 59 | void setValue(Object value) throws InvocationTargetException; |
|---|
| 60 | } |
|---|