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.resolver.validator;
\r
11 import javax.annotation.Nonnull;
\r
12 import org.opendaylight.yangtools.concepts.Builder;
\r
14 public final class ValidationResultBuilder implements Builder<ValidationResult> {
\r
16 private static final class ValidationResultImpl implements ValidationResult {
\r
18 private final boolean success;
\r
19 private final String message;
\r
21 private ValidationResultImpl(final boolean success, final String message) {
\r
22 this.success = success;
\r
23 this.message = message;
\r
27 public boolean isValid() {
\r
32 public String getMessage() {
\r
37 private boolean success;
\r
38 private String message = "";
\r
40 public ValidationResultBuilder success() {
\r
41 this.success = true;
\r
46 * Returns a builder for a failed result.
\r
48 public ValidationResultBuilder failed() {
\r
49 this.success = false;
\r
54 * Returns a builder for a failed result.
\r
56 * @param message brief explanation
\r
57 * @throws IllegalArgumentException when message is null
\r
59 public ValidationResultBuilder setMessage(@Nonnull String message) {
\r
60 if (message == null) {
\r
61 throw new IllegalArgumentException("Result message cannot be set to NULL!");
\r
63 this.message = message;
\r
68 public ValidationResult build() {
\r
69 return new ValidationResultImpl(success, message);
\r