// 
// Decompiled by Procyon v0.6.0
// 

package io.sentry;

import io.sentry.protocol.ViewHierarchy;
import java.io.File;
import org.jetbrains.annotations.NotNull;
import java.util.concurrent.Callable;
import org.jetbrains.annotations.Nullable;

public final class Attachment
{
    @Nullable
    private byte[] bytes;
    @Nullable
    private final JsonSerializable serializable;
    @Nullable
    private final Callable<byte[]> byteProvider;
    @Nullable
    private String pathname;
    @NotNull
    private final String filename;
    @Nullable
    private final String contentType;
    private final boolean addToTransactions;
    @Nullable
    private String attachmentType;
    private static final String DEFAULT_ATTACHMENT_TYPE = "event.attachment";
    private static final String VIEW_HIERARCHY_ATTACHMENT_TYPE = "event.view_hierarchy";
    
    public Attachment(@NotNull final byte[] bytes, @NotNull final String filename) {
        this(bytes, filename, null);
    }
    
    public Attachment(@NotNull final byte[] bytes, @NotNull final String filename, @Nullable final String contentType) {
        this(bytes, filename, contentType, false);
    }
    
    public Attachment(@NotNull final byte[] bytes, @NotNull final String filename, @Nullable final String contentType, final boolean addToTransactions) {
        this(bytes, filename, contentType, "event.attachment", addToTransactions);
    }
    
    public Attachment(@NotNull final byte[] bytes, @NotNull final String filename, @Nullable final String contentType, @Nullable final String attachmentType, final boolean addToTransactions) {
        this.attachmentType = "event.attachment";
        this.bytes = bytes;
        this.serializable = null;
        this.byteProvider = null;
        this.filename = filename;
        this.contentType = contentType;
        this.attachmentType = attachmentType;
        this.addToTransactions = addToTransactions;
    }
    
    public Attachment(@NotNull final JsonSerializable serializable, @NotNull final String filename, @Nullable final String contentType, @Nullable final String attachmentType, final boolean addToTransactions) {
        this.attachmentType = "event.attachment";
        this.bytes = null;
        this.serializable = serializable;
        this.byteProvider = null;
        this.filename = filename;
        this.contentType = contentType;
        this.attachmentType = attachmentType;
        this.addToTransactions = addToTransactions;
    }
    
    public Attachment(@NotNull final Callable<byte[]> byteProvider, @NotNull final String filename, @Nullable final String contentType, @Nullable final String attachmentType, final boolean addToTransactions) {
        this.attachmentType = "event.attachment";
        this.bytes = null;
        this.serializable = null;
        this.byteProvider = byteProvider;
        this.filename = filename;
        this.contentType = contentType;
        this.attachmentType = attachmentType;
        this.addToTransactions = addToTransactions;
    }
    
    public Attachment(@NotNull final String pathname) {
        this(pathname, new File(pathname).getName());
    }
    
    public Attachment(@NotNull final String pathname, @NotNull final String filename) {
        this(pathname, filename, null);
    }
    
    public Attachment(@NotNull final String pathname, @NotNull final String filename, @Nullable final String contentType) {
        this(pathname, filename, contentType, "event.attachment", false);
    }
    
    public Attachment(@NotNull final String pathname, @NotNull final String filename, @Nullable final String contentType, @Nullable final String attachmentType, final boolean addToTransactions) {
        this.attachmentType = "event.attachment";
        this.pathname = pathname;
        this.filename = filename;
        this.serializable = null;
        this.byteProvider = null;
        this.contentType = contentType;
        this.attachmentType = attachmentType;
        this.addToTransactions = addToTransactions;
    }
    
    public Attachment(@NotNull final String pathname, @NotNull final String filename, @Nullable final String contentType, final boolean addToTransactions) {
        this.attachmentType = "event.attachment";
        this.pathname = pathname;
        this.filename = filename;
        this.serializable = null;
        this.byteProvider = null;
        this.contentType = contentType;
        this.addToTransactions = addToTransactions;
    }
    
    public Attachment(@NotNull final String pathname, @NotNull final String filename, @Nullable final String contentType, final boolean addToTransactions, @Nullable final String attachmentType) {
        this.attachmentType = "event.attachment";
        this.pathname = pathname;
        this.filename = filename;
        this.serializable = null;
        this.byteProvider = null;
        this.contentType = contentType;
        this.addToTransactions = addToTransactions;
        this.attachmentType = attachmentType;
    }
    
    @Nullable
    public byte[] getBytes() {
        return this.bytes;
    }
    
    @Nullable
    public JsonSerializable getSerializable() {
        return this.serializable;
    }
    
    @Nullable
    public String getPathname() {
        return this.pathname;
    }
    
    @NotNull
    public String getFilename() {
        return this.filename;
    }
    
    @Nullable
    public String getContentType() {
        return this.contentType;
    }
    
    boolean isAddToTransactions() {
        return this.addToTransactions;
    }
    
    @Nullable
    public String getAttachmentType() {
        return this.attachmentType;
    }
    
    @Nullable
    public Callable<byte[]> getByteProvider() {
        return this.byteProvider;
    }
    
    @NotNull
    public static Attachment fromScreenshot(final byte[] screenshotBytes) {
        return new Attachment(screenshotBytes, "screenshot.png", "image/png", false);
    }
    
    @NotNull
    public static Attachment fromByteProvider(@NotNull final Callable<byte[]> provider, @NotNull final String filename, @Nullable final String contentType, final boolean addToTransactions) {
        return new Attachment(provider, filename, contentType, "event.attachment", addToTransactions);
    }
    
    @NotNull
    public static Attachment fromViewHierarchy(final ViewHierarchy viewHierarchy) {
        return new Attachment(viewHierarchy, "view-hierarchy.json", "application/json", "event.view_hierarchy", false);
    }
    
    @NotNull
    public static Attachment fromThreadDump(final byte[] bytes) {
        return new Attachment(bytes, "thread-dump.txt", "text/plain", false);
    }
}
