|
22 | 22 |
|
23 | 23 | import java.net.URLEncoder; |
24 | 24 | import java.nio.charset.StandardCharsets; |
| 25 | +import java.util.Objects; |
25 | 26 | import java.util.regex.Matcher; |
26 | 27 | import java.util.regex.Pattern; |
27 | 28 | import land.oras.exception.OrasException; |
@@ -372,4 +373,28 @@ public ContainerRef forRegistry(Registry registry) { |
372 | 373 | tag, |
373 | 374 | digest); |
374 | 375 | } |
| 376 | + |
| 377 | + @Override |
| 378 | + public boolean equals(Object o) { |
| 379 | + if (o == null || getClass() != o.getClass()) return false; |
| 380 | + ContainerRef that = (ContainerRef) o; |
| 381 | + return Objects.equals(getRegistry(), that.getRegistry()) |
| 382 | + && Objects.equals(getRepository(), that.getRepository()) |
| 383 | + && Objects.equals(getNamespace(), that.getNamespace()) |
| 384 | + && Objects.equals(getDigest(), that.getDigest()) |
| 385 | + && Objects.equals(getTag(), that.getTag()); |
| 386 | + } |
| 387 | + |
| 388 | + @Override |
| 389 | + public int hashCode() { |
| 390 | + return Objects.hash(getRegistry(), getRepository(), getNamespace(), getDigest(), getTag()); |
| 391 | + } |
| 392 | + |
| 393 | + @Override |
| 394 | + public String toString() { |
| 395 | + if (namespace != null && !namespace.isEmpty()) { |
| 396 | + return "%s/%s/%s:%s%s".formatted(registry, namespace, repository, tag, digest != null ? "@" + digest : ""); |
| 397 | + } |
| 398 | + return "%s/%s:%s%s".formatted(registry, repository, tag, digest != null ? "@" + digest : ""); |
| 399 | + } |
375 | 400 | } |
0 commit comments