Jian Li | 93a1383 | 2016-02-09 11:21:47 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016 Open Networking Laboratory |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | package org.onosproject.cpman.message; |
| 17 | |
| 18 | import org.onosproject.event.AbstractEvent; |
| 19 | import org.onosproject.cpman.ControlMessage; |
| 20 | |
Jian Li | 4545cf1 | 2016-02-10 11:06:06 -0800 | [diff] [blame] | 21 | import java.util.Collection; |
| 22 | |
Jian Li | 93a1383 | 2016-02-09 11:21:47 -0800 | [diff] [blame] | 23 | import static com.google.common.base.MoreObjects.toStringHelper; |
| 24 | |
| 25 | /** |
| 26 | * Describes control message event. |
| 27 | */ |
| 28 | public class ControlMessageEvent |
Jian Li | 4545cf1 | 2016-02-10 11:06:06 -0800 | [diff] [blame] | 29 | extends AbstractEvent<ControlMessageEvent.Type, Collection<ControlMessage>> { |
Jian Li | 93a1383 | 2016-02-09 11:21:47 -0800 | [diff] [blame] | 30 | |
| 31 | /** |
| 32 | * Type of control message events. |
| 33 | */ |
| 34 | public enum Type { |
| 35 | /** |
| 36 | * signifies that the control message stats has been updated. |
| 37 | */ |
| 38 | STATS_UPDATE |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * Creates an event of given type and the current time. |
| 43 | * |
Jian Li | 4545cf1 | 2016-02-10 11:06:06 -0800 | [diff] [blame] | 44 | * @param type control message event type |
| 45 | * @param controlMessages event control message subject |
Jian Li | 93a1383 | 2016-02-09 11:21:47 -0800 | [diff] [blame] | 46 | */ |
Jian Li | 4545cf1 | 2016-02-10 11:06:06 -0800 | [diff] [blame] | 47 | public ControlMessageEvent(Type type, Collection<ControlMessage> controlMessages) { |
| 48 | super(type, controlMessages); |
Jian Li | 93a1383 | 2016-02-09 11:21:47 -0800 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | @Override |
| 52 | public String toString() { |
| 53 | return toStringHelper(this) |
| 54 | .add("type", type()) |
| 55 | .add("subject", subject()) |
| 56 | .toString(); |
| 57 | } |
| 58 | } |