All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.runsidekick.audit.logger.dto.AuditStack Maven / Gradle / Ivy

There is a newer version: 0.0.17
Show newest version
package com.runsidekick.audit.logger.dto;

import lombok.extern.slf4j.Slf4j;

import java.util.EmptyStackException;
import java.util.Optional;
import java.util.Stack;

/**
 * @author yasin.kalafat
 */
@Slf4j
public abstract class AuditStack {

    Stack auditLogStack = new Stack();

    public AuditLog push() {
        return generateNewAuditLog();
    }

    public Optional peek() {
        try {
            return Optional.of(auditLogStack.peek());
        } catch (EmptyStackException e) {
            log.error(e.getMessage(), e);
            return Optional.empty();
        }
    }

    public void remove(AuditLog auditLog) {
        auditLogStack.remove(auditLog);
    }

    private AuditLog generateNewAuditLog() {
        AuditLog auditLog = new AuditLog();
        auditLogStack.push(auditLog);
        return auditLog;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy