1 /* 2 * Copyright 2019 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package androidx.compose.runtime 18 19 /** 20 * Stable is used to communicate some guarantees to the compose compiler about how a certain type or 21 * function will behave. 22 * 23 * When applied to a class or an interface, [Stable] indicates that the following must be true: 24 * 1) The result of [equals] will always return the same result for the same two instances. 25 * 2) When a public property of the type changes, composition will be notified. 26 * 3) All public property types are stable. 27 * 28 * When applied to a function or a property, the [Stable] annotation indicates that the function 29 * will return the same result if the same parameters are passed in. This is only meaningful if the 30 * parameters and results are themselves [Stable], [Immutable], or primitive. 31 * 32 * The invariants that this annotation implies are used for optimizations by the compose compiler, 33 * and have undefined behavior if the above assumptions are not met. As a result, one should not use 34 * this annotation unless they are certain that these conditions are satisfied. 35 * 36 * @see Immutable 37 * @see StableMarker 38 */ 39 @MustBeDocumented 40 @Target( 41 AnnotationTarget.CLASS, 42 AnnotationTarget.FUNCTION, 43 AnnotationTarget.PROPERTY_GETTER, 44 AnnotationTarget.PROPERTY 45 ) 46 @Retention(AnnotationRetention.BINARY) 47 @StableMarker 48 public annotation class Stable 49