package com.atlassian.bitbucket.ssh.event;

import com.atlassian.bitbucket.audit.Priority;
import com.atlassian.bitbucket.event.ApplicationEvent;
import com.atlassian.bitbucket.event.annotation.Audited;
import com.atlassian.bitbucket.event.annotation.TransactionAware;
import com.atlassian.bitbucket.ssh.SshKey;

import javax.annotation.Nonnull;

import static com.google.common.base.Preconditions.checkNotNull;

/**
 * Common base for all SSH key events.
 */
@Audited(converter = SshKeyEventConverter.class, priority = Priority.HIGH)
@TransactionAware
public abstract class SshKeyEvent extends ApplicationEvent {

    private final SshKey key;

    protected SshKeyEvent(@Nonnull Object source, @Nonnull SshKey key) {
        super(source);

        this.key = checkNotNull(key, "key");
    }

    @Nonnull
    public SshKey getKey() {
        return key;
    }
}
