Merge commit '42b2e5ca519766e37ce6941ba4faecc9691cc403' into upstream
[debian/openrocket] / core / src / net / sf / openrocket / preset / InvalidComponentPresetException.java
diff --git a/core/src/net/sf/openrocket/preset/InvalidComponentPresetException.java b/core/src/net/sf/openrocket/preset/InvalidComponentPresetException.java
new file mode 100644 (file)
index 0000000..c28fb09
--- /dev/null
@@ -0,0 +1,56 @@
+package net.sf.openrocket.preset;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class InvalidComponentPresetException extends Exception {
+
+       private List<String> errors = new ArrayList<String>();
+       private List<TypedKey<?>> invalidParameters = new ArrayList<TypedKey<?>>();
+       
+       public InvalidComponentPresetException() {
+               super();
+       }
+
+       public InvalidComponentPresetException(String message, Throwable cause) {
+               super(message, cause);
+       }
+
+       public InvalidComponentPresetException(String message) {
+               super(message);
+       }
+
+       public InvalidComponentPresetException(Throwable cause) {
+               super(cause);
+       }
+       
+       void addInvalidParameter(TypedKey<?> key ) {
+               invalidParameters.add(key);
+       }
+       
+       void addInvalidParameter(TypedKey<?> key, String message ) {
+               invalidParameters.add(key);
+               errors.add(message);
+       }
+       
+       void addMessage( String message ) {
+               errors.add(message);
+       }
+
+       boolean hasProblems() {
+               return (invalidParameters.size() + errors.size()) > 0;
+       }
+       
+       public int problemCount() {
+               return Math.max( invalidParameters.size(), errors.size() );
+       }
+       
+       public List<String> getErrors() {
+               return errors;
+       }
+
+       public List<TypedKey<?>> getInvalidParameters() {
+               return invalidParameters;
+       }
+       
+}