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

org.enodeframework.domain.DomainException Maven / Gradle / Ivy

There is a newer version: 1.1.10
Show newest version
package org.enodeframework.domain;

import org.enodeframework.common.utilities.IdGenerator;
import org.enodeframework.common.utilities.SystemClock;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

public abstract class DomainException extends RuntimeException implements IDomainException {
    private static final long serialVersionUID = 2099914413380872726L;
    private String id;
    private Date timestamp;
    private Map items;

    public DomainException() {
        this(IdGenerator.nextId());
    }

    public DomainException(String id) {
        this.id = id;
        this.timestamp = new Date();
        this.items = new HashMap<>();
    }

    @Override
    public abstract void serializeTo(Map serializableInfo);

    @Override
    public abstract void restoreFrom(Map serializableInfo);

    @Override
    public String getId() {
        return id;
    }

    @Override
    public void setId(String id) {
        this.id = id;
    }

    @Override
    public Date getTimestamp() {
        return timestamp;
    }

    @Override
    public void setTimestamp(Date timestamp) {
        this.timestamp = timestamp;
    }

    @Override
    public Map getItems() {
        return items;
    }

    @Override
    public void setItems(Map items) {
        this.items = items;
    }

    @Override
    public void mergeItems(Map mitems) {
        if (mitems == null || mitems.size() == 0) {
            return;
        }
        if (this.items == null) {
            this.items = new HashMap<>();
        }
        for (Map.Entry entry : mitems.entrySet()) {
            if (!this.items.containsKey(entry.getKey())) {
                this.items.put(entry.getKey(), entry.getValue());
            }
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy