nl.vpro.domain.media.exceptions.CircularReferenceException Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of media-domain Show documentation
Show all versions of media-domain Show documentation
The basic domain classes for 'media', the core of POMS. Also, the 'update' XML bindings for it.
It also contains some closely related domain classes like the enum to contain NICAM kijkwijzer settings.
/*
* Copyright (C) 2010 Licensed under the Apache License, Version 2.0
* VPRO The Netherlands
*/
package nl.vpro.domain.media.exceptions;
import java.io.Serial;
import java.util.*;
import nl.vpro.domain.media.MediaObject;
public class CircularReferenceException extends RuntimeException {
@Serial
private static final long serialVersionUID = -6557241432901240561L;
private final List familyTree = new ArrayList<>();
private CircularReferenceException(String message, MediaObject child, List ancestry) {
super(message);
familyTree.addAll(ancestry);
familyTree.add(child);
}
public CircularReferenceException(MediaObject child, MediaObject parent, List ancestry) {
this("Circular reference: " + parent + " has ancestors " + ancestry + "", child, ancestry);
}
public static CircularReferenceException self(MediaObject child, MediaObject parent, List ancestry) {
return new CircularReferenceException("Can't make " + child + " member of itself " + parent, child, ancestry);
}
public List getFamilyTree() {
return Collections.unmodifiableList(familyTree);
}
}