Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move Parameters.count() to an extension function. #403

Merged
merged 1 commit into from
May 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion coil-base/api/coil-base.api
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ public final class coil/drawable/CrossfadeDrawable$Companion {
}

public final class coil/extension/Parameters {
public static final fun count (Lcoil/request/Parameters;)I
public static final fun get (Lcoil/request/Parameters;Ljava/lang/String;)Ljava/lang/Object;
public static final fun isNotEmpty (Lcoil/request/Parameters;)Z
}
Expand Down Expand Up @@ -598,13 +599,13 @@ public final class coil/request/Parameters : java/lang/Iterable, kotlin/jvm/inte
public synthetic fun <init> (Ljava/util/Map;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun cacheKey (Ljava/lang/String;)Ljava/lang/String;
public final fun cacheKeys ()Ljava/util/Map;
public final fun count ()I
public final fun entry (Ljava/lang/String;)Lcoil/request/Parameters$Entry;
public fun equals (Ljava/lang/Object;)Z
public fun hashCode ()I
public final fun isEmpty ()Z
public fun iterator ()Ljava/util/Iterator;
public final fun newBuilder ()Lcoil/request/Parameters$Builder;
public final fun size ()I
public fun toString ()Ljava/lang/String;
public final fun value (Ljava/lang/String;)Ljava/lang/Object;
public final fun values ()Ljava/util/Map;
Expand Down
5 changes: 5 additions & 0 deletions coil-base/src/main/java/coil/extension/Parameters.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ package coil.extension

import coil.request.Parameters

/** Returns the number of parameters in this object. */
inline fun Parameters.count(): Int = size

/** Return true when the set contains elements. */
inline fun Parameters.isNotEmpty(): Boolean = !isEmpty()

/** Returns the value associated with [key] or null if [key] has no mapping. */
inline operator fun Parameters.get(key: String): Any? = value(key)
6 changes: 3 additions & 3 deletions coil-base/src/main/java/coil/request/Parameters.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ class Parameters private constructor(
): Parameters = Builder().apply(builder).build()
}

/** Returns the number of parameters in this object. */
val size: Int @JvmName("size") get() = map.size

/** Returns the value associated with [key] or null if [key] has no mapping. */
fun value(key: String): Any? = map[key]?.value

Expand All @@ -36,9 +39,6 @@ class Parameters private constructor(
/** Returns the entry associated with [key] or null if [key] has no mapping. */
fun entry(key: String): Entry? = map[key]

/** Returns the number of parameters in this object. */
fun count(): Int = map.count()

/** Returns true if this object has no parameters. */
fun isEmpty(): Boolean = map.isEmpty()

Expand Down