Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.components.offline_items_collection; | 5 package org.chromium.components.offline_items_collection; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * This class is a Java counterpart to the C++ ContentId | 8 * This class is a Java counterpart to the C++ ContentId |
| 9 * (components/offline_items_collection/core/offline_item.h) class. | 9 * (components/offline_items_collection/core/offline_item.h) class. |
| 10 * | 10 * |
| 11 * For all member variable descriptions see the C++ class. | 11 * For all member variable descriptions see the C++ class. |
| 12 * TODO(dtrainor): Investigate making all class members for this and the C++ cou nterpart const. | 12 * TODO(dtrainor): Investigate making all class members for this and the C++ cou nterpart const. |
| 13 */ | 13 */ |
| 14 public class ContentId { | 14 public class ContentId { |
| 15 public String namespace; | 15 public String namespace; |
|
qinmin
2017/03/22 07:53:58
nit: public final
| |
| 16 public String id; | 16 public String id; |
| 17 | 17 |
| 18 public ContentId() {} | 18 public ContentId() {} |
| 19 public ContentId(String namespace, String id) { | 19 public ContentId(String namespace, String id) { |
| 20 this.namespace = namespace; | 20 this.namespace = namespace; |
| 21 this.id = id; | 21 this.id = id; |
| 22 } | 22 } |
| 23 | |
|
gone
2017/03/20 19:03:36
Also randomly added?
David Trainor- moved to gerrit
2017/03/25 03:31:13
See comment in OfflineItem.java.
| |
| 24 @Override | |
| 25 public String toString() { | |
| 26 return getClass().getSimpleName() + "@" + Integer.toHexString(hashCode() ) + " [" + namespace | |
| 27 + ", " + id + "]"; | |
| 28 } | |
| 29 | |
| 30 @Override | |
| 31 public boolean equals(Object o) { | |
| 32 if (this == o) return true; | |
| 33 if (!(o instanceof ContentId)) return false; | |
| 34 | |
| 35 ContentId lhs = (ContentId) o; | |
|
fgorski
2017/03/20 20:19:20
rhs?
Both because this is right of equals and you
David Trainor- moved to gerrit
2017/03/25 03:31:13
Done.
| |
| 36 return namespace == lhs.namespace && id == lhs.id; | |
| 37 } | |
| 38 | |
| 39 @Override | |
| 40 public int hashCode() { | |
| 41 int result = 61; | |
| 42 | |
| 43 result = 31 * result + (namespace == null ? 0 : namespace.hashCode()); | |
| 44 result = 31 * result + (id == null ? 0 : id.hashCode()); | |
| 45 | |
| 46 return result; | |
| 47 } | |
| 23 } | 48 } |
| OLD | NEW |