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

pro.jk.ejoker.domain.domainException.AbstractDomainException Maven / Gradle / Ivy

package pro.jk.ejoker.domain.domainException;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

import pro.jk.ejoker.common.context.annotation.persistent.PersistentIgnore;
import pro.jk.ejoker.utils.MObjectId;

public abstract class AbstractDomainException extends RuntimeException implements IDomainException, Serializable {

	private static final long serialVersionUID = 4037848789314871750L;

	private String id;
	
	private long timestamp;
	
	@PersistentIgnore
	private Map items;
	
	public AbstractDomainException() {
        this("Domain exception.");
    }
	
	public AbstractDomainException(String msg) {
		super(msg);
        id = MObjectId.get().toHexString();
        timestamp = System.currentTimeMillis();
        items = new HashMap<>();
    }
	
	@Override
	public void setId(String id) {
		this.id = id;
	}

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

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

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

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

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

	@Override
	public void mergeItems(Map items) {
		if(null == items || items.isEmpty()) {
			return;
		}
		if(null == this.items) {
			this.items = new HashMap<>();
		}
		Set> entrySet = items.entrySet();
		for(Entry entry : entrySet) {
			this.items.putIfAbsent(entry.getKey(), entry.getValue());
		}
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy