-/*\r
- * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.groupbasedpolicy.dto;\r
-\r
-import javax.annotation.Nonnull;\r
-\r
-import org.opendaylight.groupbasedpolicy.api.ValidationResult;\r
-import org.opendaylight.yangtools.concepts.Builder;\r
-\r
-public final class ValidationResultBuilder implements Builder<ValidationResult> {\r
-\r
- public static final String ILLEGAL_ARG_EX_MSG = "Result message cannot be set to NULL!";\r
-\r
- private static final class ValidationResultImpl implements ValidationResult {\r
-\r
- private final boolean success;\r
- private final String message;\r
-\r
- private ValidationResultImpl(final boolean success, final String message) {\r
- this.success = success;\r
- this.message = message;\r
- }\r
-\r
- @Override\r
- public boolean isValid() {\r
- return success;\r
- }\r
-\r
- @Override\r
- public String getMessage() {\r
- return message;\r
- }\r
-\r
- @Override\r
- public boolean equals(Object o) {\r
- if (this == o)\r
- return true;\r
- if (o == null || getClass() != o.getClass())\r
- return false;\r
-\r
- ValidationResultImpl that = (ValidationResultImpl) o;\r
-\r
- if (success != that.success)\r
- return false;\r
- return message.equals(that.message);\r
- }\r
-\r
- @Override\r
- public int hashCode() {\r
- int result = (success ? 1 : 0);\r
- result = 31 * result + message.hashCode();\r
- return result;\r
- }\r
- }\r
-\r
- private boolean success;\r
- private String message = "";\r
-\r
- public ValidationResultBuilder success() {\r
- this.success = true;\r
- return this;\r
- }\r
-\r
- /**\r
- * Returns a builder for a failed result.\r
- */\r
- public ValidationResultBuilder failed() {\r
- this.success = false;\r
- return this;\r
- }\r
-\r
- /**\r
- * Returns a builder for a failed result.\r
- *\r
- * @param message brief explanation\r
- * @throws IllegalArgumentException when message is null\r
- */\r
- public ValidationResultBuilder setMessage(@Nonnull String message) {\r
- if (message == null) {\r
- throw new IllegalArgumentException(ILLEGAL_ARG_EX_MSG);\r
- }\r
- this.message = message;\r
- return this;\r
- }\r
-\r
- @Override\r
- public ValidationResult build() {\r
- return new ValidationResultImpl(success, message);\r
- }\r
-\r
-}\r
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.groupbasedpolicy.dto;
+
+import javax.annotation.Nonnull;
+
+import org.opendaylight.groupbasedpolicy.api.ValidationResult;
+import org.opendaylight.yangtools.concepts.Builder;
+
+public final class ValidationResultBuilder implements Builder<ValidationResult> {
+
+ public static final String ILLEGAL_ARG_EX_MSG = "Result message cannot be set to NULL!";
+
+ private static final class ValidationResultImpl implements ValidationResult {
+
+ private final boolean success;
+ private final String message;
+
+ private ValidationResultImpl(final boolean success, final String message) {
+ this.success = success;
+ this.message = message;
+ }
+
+ @Override
+ public boolean isValid() {
+ return success;
+ }
+
+ @Override
+ public String getMessage() {
+ return message;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
+
+ ValidationResultImpl that = (ValidationResultImpl) o;
+
+ if (success != that.success)
+ return false;
+ return message.equals(that.message);
+ }
+
+ @Override
+ public int hashCode() {
+ int result = (success ? 1 : 0);
+ result = 31 * result + message.hashCode();
+ return result;
+ }
+ }
+
+ private boolean success;
+ private String message = "";
+
+ public ValidationResultBuilder success() {
+ this.success = true;
+ return this;
+ }
+
+ /**
+ * Returns a builder for a failed result.
+ */
+ public ValidationResultBuilder failed() {
+ this.success = false;
+ return this;
+ }
+
+ /**
+ * Returns a builder for a failed result.
+ *
+ * @param message brief explanation
+ * @throws IllegalArgumentException when message is null
+ */
+ public ValidationResultBuilder setMessage(@Nonnull String message) {
+ if (message == null) {
+ throw new IllegalArgumentException(ILLEGAL_ARG_EX_MSG);
+ }
+ this.message = message;
+ return this;
+ }
+
+ @Override
+ public ValidationResult build() {
+ return new ValidationResultImpl(success, message);
+ }
+
+}