2 ******************************************************************************
\r
3 * Copyright (C) 2005-2008, International Business Machines Corporation and *
\r
4 * others. All Rights Reserved. *
\r
5 ******************************************************************************
\r
7 package com.ibm.icu.dev.test.util;
\r
10 * Provides a flexible mechanism for controlling access, without requiring that a class be immutable.
\r
11 * Once locked, an object can never be unlocked, so it is thread-safe from that point onward.
\r
12 * The implementation of both methods must be synchronized.
\r
13 * Once the object has been locked, it must guarantee that no changes can be made to it.
\r
14 * Any attempt to alter it must raise an UnsupportedOperationException exception.
\r
15 * This means that when the object returns internal objects,
\r
16 * or if anyone has references to those internal objects, that those internal objects must either be immutable,
\r
17 * or must also raise exceptions if any attempt to modify them is made. Of course, the object can return clones
\r
18 * of internal objects, since those are safe. * @author davis
\r
20 public interface Lockable extends Cloneable {
\r
22 * Determines whether the object has been locked or not.
\r
24 public boolean isLocked();
\r
27 * @return the object itself.
\r
29 public Object lock();
\r
31 * Provides for the clone operation. Any clone is initially unlocked.
\r
33 public Object clone();
\r