5f38f90a621721321fb9687a545182edff3a8b7e
[groupbasedpolicy.git] / renderers / ofoverlay / src / main / java / org / opendaylight / groupbasedpolicy / renderer / ofoverlay / 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.ofoverlay.sf;
10
11 import java.util.List;
12
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
14
15 import com.google.common.base.Preconditions;
16
17 public class ClassificationResult {
18
19     private final String message;
20     private final boolean isSuccessful;
21     private final List<MatchBuilder> matchBuilders;
22
23     public ClassificationResult(String errorMessage) {
24         this.message = Preconditions.checkNotNull(errorMessage);
25         this.isSuccessful = false;
26         matchBuilders = null;
27     }
28
29     public ClassificationResult(List<MatchBuilder> matches) {
30         message = "";
31         this.matchBuilders = Preconditions.checkNotNull(matches);
32         this.isSuccessful = true;
33     }
34
35     public List<MatchBuilder> getMatchBuilders() {
36         if (isSuccessful == false) {
37             throw new IllegalStateException("Classification was not successfull.");
38         }
39         return matchBuilders;
40     }
41
42     public String getMessage() {
43         return message;
44     }
45
46     public boolean isSuccessfull() {
47         return isSuccessful;
48     }
49 }