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.SshAccessKey;

import javax.annotation.Nonnull;

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

/**
 * Base implementation for SSH access key events
 *
 * @since 4.3
 */
@Audited(converter = SshAccessKeyEventConverter.class, priority = Priority.HIGH)
@TransactionAware
public abstract class SshAccessKeyEvent extends ApplicationEvent {

    private final SshAccessKey accessKey;

    protected SshAccessKeyEvent(@Nonnull Object source, @Nonnull SshAccessKey accessKey) {
        super(source);
        this.accessKey = checkNotNull(accessKey, "accessKey");
    }

    @Nonnull
    public SshAccessKey getAccessKey() {
        return accessKey;
    }
}
