1 | package de.uka.ipd.sdq.dsexplore.exception; |
2 | |
3 | import de.uka.ipd.sdq.dsexplore.helper.DegreeOfFreedomHelper; |
4 | import de.uka.ipd.sdq.pcm.designdecision.Choice; |
5 | import de.uka.ipd.sdq.pcm.designdecision.DegreeOfFreedomInstance; |
6 | import de.uka.ipd.sdq.pcm.designdecision.DiscreteRangeChoice; |
7 | import de.uka.ipd.sdq.pcm.designdecision.ClassChoice; |
8 | import de.uka.ipd.sdq.pcm.designdecision.SchedulingPolicyChoice; |
9 | |
10 | /** |
11 | * Thrown in the value of a {@link Choice} is not contained in the corresponding {@link DegreeOfFreedomInstance}. |
12 | * Example: {@link DiscreteRangeChoice} A has the chosen value 5, but the linked {@link DegreeOfFreedomInstance} D |
13 | * has from = 7 and to = 10. |
14 | * |
15 | * @author martens |
16 | * |
17 | */ |
18 | public class ChoiceOutOfBoundsException extends RuntimeException { |
19 | |
20 | /** |
21 | * |
22 | */ |
23 | private static final long serialVersionUID = -5518058966677144866L; |
24 | |
25 | public ChoiceOutOfBoundsException(ClassChoice choice){ |
26 | super("Chosen entity "+choice.getChosenValue()+" of choice "+choice.getClass().getSimpleName()+" does not exist in domain of degree "+DegreeOfFreedomHelper.getDegreeDescription(choice.getDegreeOfFreedomInstance())+" of type "+choice.getDegreeOfFreedomInstance().getClass().getSimpleName()); |
27 | } |
28 | |
29 | public ChoiceOutOfBoundsException(ClassChoice choice, String location){ |
30 | super(location+": Chosen entity "+choice.getChosenValue()+" of choice "+choice.getClass().getSimpleName()+" does not exist in domain of degree "+DegreeOfFreedomHelper.getDegreeDescription(choice.getDegreeOfFreedomInstance())+" of type "+choice.getDegreeOfFreedomInstance().getClass().getSimpleName()); |
31 | } |
32 | |
33 | public ChoiceOutOfBoundsException(SchedulingPolicyChoice choice, |
34 | String location) { |
35 | super(location+": Chosen entity "+choice.getChosenValue().getLiteral()+" of choice "+choice.getClass().getSimpleName()+" does not exist in domain of degree "+DegreeOfFreedomHelper.getDegreeDescription(choice.getDegreeOfFreedomInstance())+" of type "+choice.getDegreeOfFreedomInstance().getClass().getSimpleName()); |
36 | } |
37 | |
38 | public ChoiceOutOfBoundsException(DiscreteRangeChoice discreteChoice) { |
39 | super("Chosen value "+discreteChoice.getChosenValue()+" of choice "+discreteChoice.getClass().getSimpleName()+" does not exist in domain of degree "+DegreeOfFreedomHelper.getDegreeDescription(discreteChoice.getDegreeOfFreedomInstance())+" of type "+discreteChoice.getDegreeOfFreedomInstance().getClass().getSimpleName()); |
40 | } |
41 | |
42 | public ChoiceOutOfBoundsException(DiscreteRangeChoice discreteChoice, String message) { |
43 | super("Chosen value "+discreteChoice.getChosenValue()+" of choice "+discreteChoice.getClass().getSimpleName()+" does not exist in domain of degree "+DegreeOfFreedomHelper.getDegreeDescription(discreteChoice.getDegreeOfFreedomInstance())+" of type "+discreteChoice.getDegreeOfFreedomInstance().getClass().getSimpleName()+". Details: "+message); |
44 | } |
45 | |
46 | |
47 | } |