| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| CircleException |
|
| 0.0;0 |
| 1 | /* | |
| 2 | Copyright (c) 2006, University of Tromsø | |
| 3 | All rights reserved. | |
| 4 | ||
| 5 | Redistribution and use in source and binary forms, with or without | |
| 6 | modification, are permitted provided that the following conditions are met: | |
| 7 | ||
| 8 | * Redistributions of source code must retain the above copyright notice, this list | |
| 9 | of conditions and the following disclaimer. | |
| 10 | ||
| 11 | * Redistributions in binary form must reproduce the above copyright notice, this | |
| 12 | list of conditions and the following disclaimer in the documentation and/or other | |
| 13 | materials provided with the distribution. | |
| 14 | ||
| 15 | * Neither the name of the University of Tromsø nor the names of its contributors may | |
| 16 | be used to endorse or promote products derived from this software without specific | |
| 17 | prior written permission. | |
| 18 | ||
| 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY | |
| 20 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |
| 21 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT | |
| 22 | SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | |
| 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED | |
| 24 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR | |
| 25 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
| 26 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | |
| 27 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH | |
| 28 | DAMAGE. | |
| 29 | */ | |
| 30 | ||
| 31 | package argos.metadata; | |
| 32 | ||
| 33 | import java.util.List; | |
| 34 | ||
| 35 | import argos.util.graph.Node; | |
| 36 | ||
| 37 | public class CircleException extends Exception { | |
| 38 | private static final long serialVersionUID = 1L; | |
| 39 | ||
| 40 | private String message; | |
| 41 | ||
| 42 | public CircleException(List<Node> circle) { | |
| 43 | 0 | super(); |
| 44 | 0 | message = createExceptionMessage(circle); |
| 45 | 0 | } |
| 46 | ||
| 47 | @Override public String getMessage() { | |
| 48 | 0 | return message; |
| 49 | } | |
| 50 | ||
| 51 | public static String createExceptionMessage(List<Node> circle) { | |
| 52 | 0 | StringBuilder sb = new StringBuilder(); |
| 53 | 0 | sb.append("Circle dependency: "); |
| 54 | 0 | for(Node node : circle) { |
| 55 | 0 | sb.append(node.getName()); |
| 56 | 0 | sb.append(" --> "); |
| 57 | } | |
| 58 | 0 | sb.append(circle.get(0).getName()); |
| 59 | 0 | return sb.toString(); |
| 60 | } | |
| 61 | } |