2 * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
\r
4 * This program and the accompanying materials are made available under the
\r
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
\r
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
\r
8 package org.opendaylight.groupbasedpolicy.dto;
\r
11 import javax.annotation.Nonnull;
\r
13 import org.opendaylight.groupbasedpolicy.api.ValidationResult;
\r
14 import org.opendaylight.yangtools.concepts.Builder;
\r
16 public final class ValidationResultBuilder implements Builder<ValidationResult> {
\r
18 private static final class ValidationResultImpl implements ValidationResult {
\r
20 private final boolean success;
\r
21 private final String message;
\r
23 private ValidationResultImpl(final boolean success, final String message) {
\r
24 this.success = success;
\r
25 this.message = message;
\r
29 public boolean isValid() {
\r
34 public String getMessage() {
\r
39 private boolean success;
\r
40 private String message = "";
\r
42 public ValidationResultBuilder success() {
\r
43 this.success = true;
\r
48 * Returns a builder for a failed result.
\r
50 public ValidationResultBuilder failed() {
\r
51 this.success = false;
\r
56 * Returns a builder for a failed result.
\r
58 * @param message brief explanation
\r
59 * @throws IllegalArgumentException when message is null
\r
61 public ValidationResultBuilder setMessage(@Nonnull String message) {
\r
62 if (message == null) {
\r
63 throw new IllegalArgumentException("Result message cannot be set to NULL!");
\r
65 this.message = message;
\r
70 public ValidationResult build() {
\r
71 return new ValidationResultImpl(success, message);
\r