kotlin.jvm.internal.PropertyReference Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kotlin-stdlib Show documentation
Show all versions of kotlin-stdlib Show documentation
Kotlin Standard Library for JVM
/*
* Copyright 2010-2018 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.
*/
package kotlin.jvm.internal;
import kotlin.SinceKotlin;
import kotlin.reflect.KCallable;
import kotlin.reflect.KProperty;
public abstract class PropertyReference extends CallableReference implements KProperty {
public PropertyReference() {
super();
}
@SinceKotlin(version = "1.1")
public PropertyReference(Object receiver) {
super(receiver);
}
@Override
@SinceKotlin(version = "1.1")
protected KProperty getReflected() {
return (KProperty) super.getReflected();
}
@Override
@SinceKotlin(version = "1.1")
public boolean isLateinit() {
return getReflected().isLateinit();
}
@Override
@SinceKotlin(version = "1.1")
public boolean isConst() {
return getReflected().isConst();
}
@Override
public boolean equals(Object obj) {
if (obj == this) return true;
if (obj instanceof PropertyReference) {
PropertyReference other = (PropertyReference) obj;
return getOwner().equals(other.getOwner()) &&
getName().equals(other.getName()) &&
getSignature().equals(other.getSignature()) &&
Intrinsics.areEqual(getBoundReceiver(), other.getBoundReceiver());
}
if (obj instanceof KProperty) {
return obj.equals(compute());
}
return false;
}
@Override
public int hashCode() {
return (getOwner().hashCode() * 31 + getName().hashCode()) * 31 + getSignature().hashCode();
}
@Override
public String toString() {
KCallable reflected = compute();
if (reflected != this) {
return reflected.toString();
}
return "property " + getName() + Reflection.REFLECTION_NOT_AVAILABLE;
}
}