Skip to content

Commit

Permalink
Merge pull request square#4842 from amirlivneh/cookie-data-class
Browse files Browse the repository at this point in the history
Convert Cookie to a data class
  • Loading branch information
swankjesse committed Mar 31, 2019
2 parents eac9c29 + e926555 commit 91912ac
Showing 1 changed file with 1 addition and 29 deletions.
30 changes: 1 addition & 29 deletions okhttp/src/main/java/okhttp3/Cookie.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import java.util.regex.Pattern
*
* [chromium_extension]: https://code.google.com/p/chromium/issues/detail?id=232693
*/
class Cookie private constructor(
data class Cookie private constructor(
private val name: String,
private val value: String,
private val expiresAt: Long,
Expand Down Expand Up @@ -242,34 +242,6 @@ class Cookie private constructor(
}
}

override fun equals(other: Any?): Boolean {
if (other !is Cookie) return false
val that = other as Cookie?
return (that!!.name == name
&& that.value == value
&& that.domain == domain
&& that.path == path
&& that.expiresAt == expiresAt
&& that.secure == secure
&& that.httpOnly == httpOnly
&& that.persistent == persistent
&& that.hostOnly == hostOnly)
}

override fun hashCode(): Int {
var hash = 17
hash = 31 * hash + name.hashCode()
hash = 31 * hash + value.hashCode()
hash = 31 * hash + domain.hashCode()
hash = 31 * hash + path.hashCode()
hash = 31 * hash + (expiresAt xor expiresAt.ushr(32)).toInt()
hash = 31 * hash + if (secure) 0 else 1
hash = 31 * hash + if (httpOnly) 0 else 1
hash = 31 * hash + if (persistent) 0 else 1
hash = 31 * hash + if (hostOnly) 0 else 1
return hash
}

companion object {
private val YEAR_PATTERN = Pattern.compile("(\\d{2,4})[^\\d]*")
private val MONTH_PATTERN =
Expand Down

0 comments on commit 91912ac

Please sign in to comment.