aboutsummaryrefslogtreecommitdiffstats
path: root/component/src/main/java/com/yahoo/component/provider/Freezable.java
blob: 22300a3cdc36450edacdfe94325b4ed49c0a9b9c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.component.provider;

/**
 * A class which may be irreversibly frozen. Any attempt to change the state of this class after
 * freezing throws an IllegalStateException.
 *
 * @author bratseth
 */
public interface Freezable {

    /**
     * Freezes this component to prevent further changes. Override this to freeze internal data
     * structures and dependent objects. Overrides must call super.
     * Calling freeze on an already frozen class must have no effect.
     */
    void freeze();


    /**
     * Inspect whether this object can be changed. If the object is immutable
     * from construction, this should return true, even if freeze() never has
     * been invoked.
     *
     * @return true if this instance is in an immutable state, false otherwise
     * @since 5.1.4
     */
    boolean isFrozen();

}