This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Copyright 2020 Google LLC. | |
SPDX-License-Identifier: Apache-2.0 --> | |
public actual fun <T> lazy(initializer: () -> T): Lazy<T> = | |
SynchronizedLazyImpl(initializer) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Copyright 2020 Google LLC. | |
SPDX-License-Identifier: Apache-2.0 --> | |
this.fullname$delegate = LazyKt.lazy((Function0)(new Function0() { | |
@NotNull | |
public final String invoke() { | |
return name + lastname; | |
} | |
})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Copyright 2020 Google LLC. | |
SPDX-License-Identifier: Apache-2.0 --> | |
@NotNull | |
private final Lazy fullname$delegate; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Copyright 2020 Google LLC. | |
SPDX-License-Identifier: Apache-2.0 --> | |
class Person(name: String, lastname: String) { | |
val fullname: String by lazy() { | |
name + lastname | |
} | |
//... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Copyright 2019 Google LLC. | |
SPDX-License-Identifier: Apache-2.0 --> | |
override fun setValue( | |
thisRef: Any?, | |
property: KProperty<*>, | |
value: String | |
) { | |
if (thisRef is Person) { | |
thisRef.updateCount++ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Copyright 2019 Google LLC. | |
SPDX-License-Identifier: Apache-2.0 --> | |
class FormatDelegate : ReadWriteProperty<Any?, String> { | |
private var formattedString: String = "" | |
override fun getValue( | |
thisRef: Any?, | |
property: KProperty<*> | |
): String { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Copyright 2019 Google LLC. | |
SPDX-License-Identifier: Apache-2.0 --> | |
class Person(name: String, lastname: String) { | |
var name: String by FormatDelegate() | |
var lastname: String by FormatDelegate() | |
var updateCount = 0 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Copyright 2019 Google LLC. | |
SPDX-License-Identifier: Apache-2.0 --> | |
class Person(name: String, lastname: String) { | |
var name: String = name | |
set(value) { | |
field = value.toLowerCase().capitalize() | |
updateCount++ | |
} | |
var lastname: String = lastname |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Copyright 2019 Google LLC. | |
SPDX-License-Identifier: Apache-2.0 --> | |
class Person(name: String, var lastname: String) { | |
var name: String = name | |
set(value) { | |
field = value.toLowerCase().capitalize() | |
updateCount++ | |
} | |
var updateCount = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public final class ListWithTrash implements Collection, KMutableCollection { | |
@Nullable | |
private Object deletedItem; | |
private final List innerList; | |
@Nullable | |
public final Object getDeletedItem() { | |
return this.deletedItem; | |
} |