Fix license header violations in test-common
[openflowplugin.git] / test-common / src / main / java / org / opendaylight / openflowplugin / testcommon / DropTestStats.java
1 /*
2  * Copyright (c) 2015 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.openflowplugin.testcommon;
10
11 public class DropTestStats {
12     private final int rcvd;
13     private final int sent;
14     private final int excs;
15     private volatile int ftrSuccess;
16     protected volatile int ftrFailed;
17     private final int runablesExecuted;
18     private final int runablesRejected;
19
20     private final String message;
21
22     public DropTestStats(int sent, int rcvd) {
23         this.sent = sent;
24         this.rcvd = rcvd;
25         this.excs = 0;
26         this.runablesExecuted = 0;
27         this.message = null;
28         runablesRejected = 0;
29     }
30
31     public DropTestStats(int sent, int rcvd, int excs) {
32         this.sent = sent;
33         this.rcvd = rcvd;
34         this.excs = excs;
35         this.message = null;
36         this.runablesExecuted = 0;
37         runablesRejected = 0;
38     }
39
40     public DropTestStats(int sent, int rcvd, int excs, int ftrFailed, int ftrSuccess, int runablesExecuted, int runablesRejected) {
41         this.sent = sent;
42         this.rcvd = rcvd;
43         this.excs = excs;
44         this.ftrFailed = ftrFailed;
45         this.ftrSuccess = ftrSuccess;
46         this.message = null;
47         this.runablesExecuted = runablesExecuted;
48         this.runablesRejected = runablesRejected;
49     }
50
51     public DropTestStats(String message) {
52         this.sent = -1;
53         this.rcvd = -1;
54         this.excs = -1;
55         this.message = message;
56         this.runablesExecuted = -1;
57         runablesRejected = 0;
58     }
59
60     public int getSent() {
61         return this.sent;
62     }
63
64     public int getRcvd() {
65         return this.rcvd;
66     }
67
68     public String getMessage() {
69         return this.message;
70     }
71
72     @Override
73     public String toString() {
74         StringBuilder result = new StringBuilder();
75         if (this.message == null) {
76             result.append("\n Rcvd:");
77             result.append(this.rcvd);
78             result.append("\n Sent: ");
79             result.append(this.sent);
80             result.append("\n Exceptions: ");
81             result.append(this.excs);
82
83             result.append("\n future success :");
84             result.append(this.ftrSuccess);
85             result.append("\n future failed :");
86             result.append(this.ftrFailed);
87             result.append("\n run() executions :");
88             result.append(this.runablesExecuted);
89             result.append("\n run() rejected :");
90             result.append(this.runablesRejected);
91
92         } else {
93             result.append(this.message);
94         }
95
96         return result.toString();
97     }
98
99 }