Skip to content

Commit 04edda0

Browse files
committed
Rename AttachmentContainer to Attachments
1 parent f916def commit 04edda0

File tree

7 files changed

+32
-32
lines changed

7 files changed

+32
-32
lines changed

sentry/api/sentry.api

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1836,7 +1836,7 @@ public final class io/sentry/exception/SentryEnvelopeException : java/lang/Excep
18361836
public abstract interface class io/sentry/hints/ApplyScopeData {
18371837
}
18381838

1839-
public final class io/sentry/hints/AttachmentContainer {
1839+
public final class io/sentry/hints/Attachments {
18401840
public fun <init> ()V
18411841
public fun add (Lio/sentry/Attachment;)V
18421842
public fun addAll (Ljava/util/List;)V
@@ -1860,7 +1860,7 @@ public final class io/sentry/hints/Hints {
18601860
public fun <init> ()V
18611861
public fun get (Ljava/lang/String;)Ljava/lang/Object;
18621862
public fun getAs (Ljava/lang/String;Ljava/lang/Class;)Ljava/lang/Object;
1863-
public fun getAttachmentContainer ()Lio/sentry/hints/AttachmentContainer;
1863+
public fun getAttachments ()Lio/sentry/hints/Attachments;
18641864
public fun remove (Ljava/lang/String;)V
18651865
public fun set (Ljava/lang/String;Ljava/lang/Object;)V
18661866
public static fun withAttachment (Lio/sentry/Attachment;)Lio/sentry/hints/Hints;

sentry/src/main/java/io/sentry/SentryClient.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ private boolean shouldApplyScopeData(
196196

197197
private void addScopeAttachmentsToHints(@Nullable Scope scope, @NotNull Hints hints) {
198198
if (scope != null) {
199-
hints.getAttachmentContainer().addAll(scope.getAttachments());
199+
hints.getAttachments().addAll(scope.getAttachments());
200200
}
201201
}
202202

@@ -227,7 +227,7 @@ private boolean shouldSendSessionUpdateForDroppedEvent(
227227
}
228228

229229
private @Nullable List<Attachment> getAttachments(final @NotNull Hints hints) {
230-
@NotNull final List<Attachment> attachments = hints.getAttachmentContainer().getAll();
230+
@NotNull final List<Attachment> attachments = hints.getAttachments().getAll();
231231

232232
@Nullable final Attachment screenshot = hints.getAs(SENTRY_SCREENSHOT, Attachment.class);
233233
if (screenshot != null) {

sentry/src/main/java/io/sentry/hints/AttachmentContainer.java renamed to sentry/src/main/java/io/sentry/hints/Attachments.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import org.jetbrains.annotations.NotNull;
77
import org.jetbrains.annotations.Nullable;
88

9-
public final class AttachmentContainer {
9+
public final class Attachments {
1010

1111
private final @NotNull List<Attachment> internalStorage = new CopyOnWriteArrayList<>();
1212

sentry/src/main/java/io/sentry/hints/Hints.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ public final class Hints {
1515

1616
public static @NotNull Hints withAttachment(@Nullable Attachment attachment) {
1717
@NotNull final Hints hints = new Hints();
18-
hints.getAttachmentContainer().add(attachment);
18+
hints.getAttachments().add(attachment);
1919
return hints;
2020
}
2121

2222
public static @NotNull Hints withAttachments(@Nullable List<Attachment> attachments) {
2323
@NotNull final Hints hints = new Hints();
24-
hints.getAttachmentContainer().addAll(attachments);
24+
hints.getAttachments().addAll(attachments);
2525
return hints;
2626
}
2727

@@ -48,16 +48,16 @@ public void remove(@NotNull String hintName) {
4848
internalStorage.remove(hintName);
4949
}
5050

51-
public @NotNull AttachmentContainer getAttachmentContainer() {
51+
public @NotNull Attachments getAttachments() {
5252
if (internalStorage.containsKey(SENTRY_ATTACHMENTS)) {
53-
AttachmentContainer container = getAs(SENTRY_ATTACHMENTS, AttachmentContainer.class);
53+
Attachments container = getAs(SENTRY_ATTACHMENTS, Attachments.class);
5454
if (container != null) {
5555
return container;
5656
}
5757
}
5858

59-
AttachmentContainer attachmentContainer = new AttachmentContainer();
60-
internalStorage.put(SENTRY_ATTACHMENTS, attachmentContainer);
61-
return attachmentContainer;
59+
Attachments attachments = new Attachments();
60+
internalStorage.put(SENTRY_ATTACHMENTS, attachments);
61+
return attachments;
6262
}
6363
}

sentry/src/test/java/io/sentry/SentryClientTest.kt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1618,8 +1618,8 @@ class SentryClientTest {
16181618
fun `can add to attachments in beforeSend`() {
16191619
val sut = fixture.getSut { options ->
16201620
options.setBeforeSend { event, hints ->
1621-
assertEquals(listOf(fixture.attachment, fixture.attachment2), hints.attachmentContainer.all)
1622-
hints.attachmentContainer.add(fixture.attachment3)
1621+
assertEquals(listOf(fixture.attachment, fixture.attachment2), hints.attachments.all)
1622+
hints.attachments.add(fixture.attachment3)
16231623
event
16241624
}
16251625
}
@@ -1635,7 +1635,7 @@ class SentryClientTest {
16351635
fun `can replace attachments in beforeSend`() {
16361636
val sut = fixture.getSut { options ->
16371637
options.setBeforeSend { event, hints ->
1638-
hints.attachmentContainer.replaceAll(listOf(fixture.attachment))
1638+
hints.attachments.replaceAll(listOf(fixture.attachment))
16391639
event
16401640
}
16411641
}
@@ -1652,8 +1652,8 @@ class SentryClientTest {
16521652
val sut = fixture.getSut { options ->
16531653
options.addEventProcessor(object : EventProcessor {
16541654
override fun process(event: SentryEvent, hints: Hints): SentryEvent? {
1655-
assertEquals(listOf(fixture.attachment, fixture.attachment2), hints.attachmentContainer.all)
1656-
hints.attachmentContainer.add(fixture.attachment3)
1655+
assertEquals(listOf(fixture.attachment, fixture.attachment2), hints.attachments.all)
1656+
hints.attachments.add(fixture.attachment3)
16571657
return event
16581658
}
16591659

@@ -1678,7 +1678,7 @@ class SentryClientTest {
16781678
val sut = fixture.getSut { options ->
16791679
options.addEventProcessor(object : EventProcessor {
16801680
override fun process(event: SentryEvent, hints: Hints): SentryEvent? {
1681-
hints.attachmentContainer.replaceAll(listOf(fixture.attachment))
1681+
hints.attachments.replaceAll(listOf(fixture.attachment))
16821682
return event
16831683
}
16841684

@@ -1740,8 +1740,8 @@ class SentryClientTest {
17401740
transaction: SentryTransaction,
17411741
hints: Hints
17421742
): SentryTransaction? {
1743-
assertEquals(listOf(fixture.attachment, fixture.attachment2), hints.attachmentContainer.all)
1744-
hints.attachmentContainer.add(fixture.attachment3)
1743+
assertEquals(listOf(fixture.attachment, fixture.attachment2), hints.attachments.all)
1744+
hints.attachments.add(fixture.attachment3)
17451745
return transaction
17461746
}
17471747
})
@@ -1771,7 +1771,7 @@ class SentryClientTest {
17711771
transaction: SentryTransaction,
17721772
hints: Hints
17731773
): SentryTransaction? {
1774-
hints.attachmentContainer.replaceAll(listOf(fixture.attachment))
1774+
hints.attachments.replaceAll(listOf(fixture.attachment))
17751775
return transaction
17761776
}
17771777
})
@@ -1809,7 +1809,7 @@ class SentryClientTest {
18091809
fun `adding attachments in beforeBreadcrumb ignores them`() {
18101810
val sut = fixture.getSut { options ->
18111811
options.setBeforeBreadcrumb { breadcrumb, hints ->
1812-
hints.attachmentContainer.add(fixture.attachment)
1812+
hints.attachments.add(fixture.attachment)
18131813
breadcrumb
18141814
}
18151815
}

sentry/src/test/java/io/sentry/hints/AttachmentContainerTest.kt renamed to sentry/src/test/java/io/sentry/hints/AttachmentsTest.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import io.sentry.Attachment
44
import kotlin.test.Test
55
import kotlin.test.assertEquals
66

7-
class AttachmentContainerTest {
7+
class AttachmentsTest {
88

99
@Test
1010
fun `can add an attachment`() {
11-
val container = AttachmentContainer()
11+
val container = Attachments()
1212
val attachment = newAttachment("test1")
1313
container.add(attachment)
1414

@@ -17,7 +17,7 @@ class AttachmentContainerTest {
1717

1818
@Test
1919
fun `can add multiple attachments`() {
20-
val container = AttachmentContainer()
20+
val container = Attachments()
2121
val attachment1 = newAttachment("test1")
2222
val attachment2 = newAttachment("test2")
2323
container.add(attachment1)
@@ -28,7 +28,7 @@ class AttachmentContainerTest {
2828

2929
@Test
3030
fun `after reset list is empty`() {
31-
val container = AttachmentContainer()
31+
val container = Attachments()
3232
val attachment1 = newAttachment("test1")
3333
val attachment2 = newAttachment("test2")
3434
container.add(attachment1)
@@ -41,7 +41,7 @@ class AttachmentContainerTest {
4141

4242
@Test
4343
fun `after replace list contains only new item`() {
44-
val container = AttachmentContainer()
44+
val container = Attachments()
4545
val attachment1 = newAttachment("test1")
4646
val attachment2 = newAttachment("test2")
4747
val attachment3 = newAttachment("test2")

sentry/src/test/java/io/sentry/hints/HintsTest.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package io.sentry.hints
22

3-
import io.sentry.hints.AttachmentContainerTest.Companion.newAttachment
3+
import io.sentry.hints.AttachmentsTest.Companion.newAttachment
44
import kotlin.test.Test
55
import kotlin.test.assertEquals
66
import kotlin.test.assertNotNull
@@ -79,23 +79,23 @@ class HintsTest {
7979
}
8080

8181
@Test
82-
fun `can retrieve AttachmentContainer`() {
82+
fun `can retrieve Attachments`() {
8383
val hints = Hints()
84-
assertNotNull(hints.attachmentContainer)
84+
assertNotNull(hints.attachments)
8585
}
8686

8787
@Test
8888
fun `can create hints with attachment`() {
8989
val attachment = newAttachment("test1")
9090
val hints = Hints.withAttachment(attachment)
91-
assertEquals(listOf(attachment), hints.attachmentContainer.all)
91+
assertEquals(listOf(attachment), hints.attachments.all)
9292
}
9393

9494
@Test
9595
fun `can create hints with attachments`() {
9696
val attachment1 = newAttachment("test1")
9797
val attachment2 = newAttachment("test1")
9898
val hints = Hints.withAttachments(listOf(attachment1, attachment2))
99-
assertEquals(listOf(attachment1, attachment2), hints.attachmentContainer.all)
99+
assertEquals(listOf(attachment1, attachment2), hints.attachments.all)
100100
}
101101
}

0 commit comments

Comments
 (0)