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

com.icthh.xm.commons.messaging.event.system.SystemEvent Maven / Gradle / Ivy

There is a newer version: 4.0.17
Show newest version
package com.icthh.xm.commons.messaging.event.system;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import lombok.ToString;
import org.apache.commons.lang3.StringUtils;

import java.time.Instant;
import java.util.Collections;
import java.util.Map;

/**
 * The {@link SystemEvent} class.
 */
@Data
@ToString(exclude = "data")
public class SystemEvent {

    private String eventId;
    private String messageSource;
    private String tenantKey;
    private String userLogin;
    private String eventType;
    @JsonIgnore
    private Instant startDate = Instant.now();
    private Object data;

    // FIXME this conversion should be on JSON marshaller level only (code used only to represents date as str in json)
    @JsonProperty("startDate")
    public String getStartDate() {
        return startDate.toString();
    }

    // FIXME this conversion should be on JSON marshaller level only (code used only to parse date from str in json)
    public void setStartDate(String startDate) {
        if (StringUtils.isNotBlank(startDate)) {
            this.startDate = Instant.parse(startDate);
        }
    }

    /**
     * Get data as Map.
     *
     * @return map with data
     */
    @JsonIgnore
    @SuppressWarnings("unchecked")
    public Map getDataMap() {
        if (data instanceof Map) {
            return (Map) data;
        }
        return Collections.emptyMap();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy