Fix serialization errors

This commit is contained in:
René Pfeuffer
2018-11-27 14:20:28 +01:00
parent b9458f47e9
commit 338d065708
3 changed files with 21 additions and 11 deletions

View File

@@ -6,6 +6,8 @@ import static java.util.Collections.unmodifiableList;
public abstract class ExceptionWithContext extends RuntimeException {
private static final long serialVersionUID = 4327413456580409224L;
private final List<ContextEntry> context;
public ExceptionWithContext(List<ContextEntry> context, String message) {

View File

@@ -7,6 +7,8 @@ import static java.util.stream.Collectors.joining;
public class NotFoundException extends ExceptionWithContext {
private static final long serialVersionUID = 1710455380886499111L;
private static final String CODE = "AGR7UzkhA1";
public NotFoundException(Class type, String id) {

View File

@@ -1,19 +1,22 @@
package sonia.scm;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import static java.util.Collections.unmodifiableCollection;
public class ScmConstraintViolationException extends RuntimeException {
public class ScmConstraintViolationException extends RuntimeException implements Serializable {
private static final long serialVersionUID = 6904534307450229887L;
private final Collection<ScmConstraintViolation> violations;
private final String furtherInformations;
private final String furtherInformation;
private ScmConstraintViolationException(Collection<ScmConstraintViolation> violations, String furtherInformations) {
private ScmConstraintViolationException(Collection<ScmConstraintViolation> violations, String furtherInformation) {
this.violations = violations;
this.furtherInformations = furtherInformations;
this.furtherInformation = furtherInformation;
}
public Collection<ScmConstraintViolation> getViolations() {
@@ -21,12 +24,12 @@ public class ScmConstraintViolationException extends RuntimeException {
}
public String getUrl() {
return furtherInformations;
return furtherInformation;
}
public static class Builder {
private final Collection<ScmConstraintViolation> violations = new ArrayList<>();
private String furtherInformations;
private String furtherInformation;
public static Builder doThrow() {
Builder builder = new Builder();
@@ -35,7 +38,7 @@ public class ScmConstraintViolationException extends RuntimeException {
public Builder andThrow() {
this.violations.clear();
this.furtherInformations = null;
this.furtherInformation = null;
return this;
}
@@ -44,19 +47,22 @@ public class ScmConstraintViolationException extends RuntimeException {
return this;
}
public Builder withFurtherInformations(String furtherInformations) {
this.furtherInformations = furtherInformations;
public Builder withFurtherInformation(String furtherInformation) {
this.furtherInformation = furtherInformation;
return this;
}
public void when(boolean condition) {
if (condition && !this.violations.isEmpty()) {
throw new ScmConstraintViolationException(violations, furtherInformations);
throw new ScmConstraintViolationException(violations, furtherInformation);
}
}
}
public static class ScmConstraintViolation {
public static class ScmConstraintViolation implements Serializable {
private static final long serialVersionUID = -6900317468157084538L;
private final String message;
private final String path;