2 * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.groupbasedpolicy.resolver.validator;
11 * Class that represents simple result (e.g. SUCCESS/FAILURE and description of
12 * that result). Provide option to save custom result (state/code), which can be
13 * evaluated by other processes.
15 * @see SimpleResult#code
18 public class SimpleResult {
23 private final int code;
25 * Description of result.
27 private final String description;
30 * Construct new {@link SimpleResult}.
32 * @param result State of result ({@code true} on success and {@code false}
34 * @param description Description of result.
36 public SimpleResult(boolean result, String description) {
37 this.code = result ? 0 : 1;
38 this.description = description;
42 * Construct new {@link SimpleResult} with empty description.
44 * @param result State of result ({@code true} on SUCCESS and {@code false}
47 public SimpleResult(boolean result) {
52 * Construct new {@link SimpleResult}.
54 * @param code Code of result, where 0 is expected as SUCCESS and everything
56 * @param description Description of result.
58 public SimpleResult(int code, String description) {
60 this.description = description;
64 * Construct new {@link SimpleResult} with empty description.
66 * @param code Code of result, where 0 is expected as SUCCESS and everything
69 public SimpleResult(int code) {
74 * Returns code of result.
76 * @return Code of result
78 public int getCode() {
83 * Returns {@code true} if code of result IS {@code 0}, otherwise returns
86 * @return {@code true} or {@code false} based on value of {@code code}
88 public boolean isSuccess() {
89 return getCode() == 0;
93 * Returns {@code true} if code of result IS NOT {@code 0}, otherwise
94 * returns {@code false}.
96 * @return {@code true} or {@code false} based on value of {@code code}
98 public boolean isFailure() {
103 * Returns saved description of result or empty string.
105 * @return Description of result.
107 public String getDescription() {
108 if (description == null) {