Skip to content

Method: message(Name)

1: package de.fhdw.wtf.facade;
2:
3: import de.fhdw.wtf.common.ast.Name;
4: import de.fhdw.wtf.common.exception.walker.TaskException;
5:
6: /**
7: * A class that represents exception that occure when a generated name is too long.
8: */
9: public class GeneratedNameTooLongException extends TaskException {
10:         
11:         /**
12:          * Creates the message for this exception.
13:          *
14:          * @param generatedName
15:          * The Name that was too long.
16:          * @return The message as String that the generatedName is too long.
17:          */
18:         private static String message(final Name generatedName) {
19:                 return "The generated name " + generatedName.toString() + " is to long. (max. length: "
20:                                 + TypeNameGenerator.getInstance().getMaxNameLength() + ")";
21:         }
22:         
23:         /**
24:          * The UID for serialization.
25:          */
26:         private static final long serialVersionUID = 1L;
27:         
28:         /**
29:          * The Name that is too long.
30:          */
31:         private final Name generatedName;
32:         
33:         /**
34:          * Creates a new exception that contains a message that <code>generatedName</code> is too long.
35:          *
36:          * @param generatedName
37:          * The Name that is too long.
38:          */
39:         public GeneratedNameTooLongException(final Name generatedName) {
40:                 super(message(generatedName));
41:                 this.generatedName = generatedName;
42:         }
43:         
44:         /**
45:          * Returns the generated name that was too long.
46:          *
47:          * @return Name that was too long
48:          */
49:         public Name getGeneratedName() {
50:                 return this.generatedName;
51:         }
52: }