All Downloads are FREE. Search and download functionalities are using the official Maven repository.

kotlinx.parcelize.parcelableCreator.kt Maven / Gradle / Ivy

There is a newer version: 2.1.0
Show newest version
/*
 * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
 * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
 */

@file:Suppress("unused")
package kotlinx.parcelize

import android.os.Parcelable

/**
 * Read the CREATOR field of the given [Parcelable] class. Calls to this function with
 * a concrete class will be optimized to a direct field access.
 */
@Suppress("UNCHECKED_CAST")
inline fun  parcelableCreator(): Parcelable.Creator =
    T::class.java.getDeclaredField("CREATOR").get(null) as? Parcelable.Creator
        ?: throw IllegalArgumentException("Could not access CREATOR field in class ${T::class.simpleName}")




© 2015 - 2024 Weber Informatics LLC | Privacy Policy