Tests for iovisor.sf
[groupbasedpolicy.git] / renderers / iovisor / src / main / java / org / opendaylight / groupbasedpolicy / renderer / iovisor / sf / ClassificationResult.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.groupbasedpolicy.renderer.iovisor.sf;
10
11 import java.util.List;
12
13 import com.google.common.base.Preconditions;
14
15 public class ClassificationResult {
16
17     static final String DEFAULT_ERROR_MESSAGE = "";
18     private final String errorMessage;
19     private final boolean isSuccessful;
20
21     /**
22      * @param errorMessage cannot be {@code null}
23      */
24     public ClassificationResult(String errorMessage) {
25         this.errorMessage = Preconditions.checkNotNull(errorMessage);
26         this.isSuccessful = false;
27     }
28
29     /**
30      * @param matches cannot be {@code null}
31      */
32     public ClassificationResult(List<String> matches) {
33         errorMessage = DEFAULT_ERROR_MESSAGE;
34         this.isSuccessful = true;
35     }
36
37     /**
38      * @return contains error message if {@link #isSuccessfull()} == {@code false}
39      */
40     public String getErrorMessage() {
41         return errorMessage;
42     }
43
44     /**
45      * @return {@code true} if {@link ClassificationResult} contains result. {@code false} if
46      *         {@link ClassificationResult} contains error message.
47      */
48     public boolean isSuccessfull() {
49         return isSuccessful;
50     }
51 }