org.enodeframework.domain.DomainException Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of enode Show documentation
Show all versions of enode Show documentation
The enodeframework core implementation.
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());
}
}
}
}