blob: c2ea1968923b897a88615e46232ba6d6afb68c4a [file] [log] [blame]
alshabibbc371962015-07-09 22:26:21 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
alshabibbc371962015-07-09 22:26:21 -07003 *
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 */
alshabib10c810b2015-08-18 16:59:04 -070016package org.onosproject.net.meter;
alshabibbc371962015-07-09 22:26:21 -070017
18import com.google.common.base.MoreObjects;
alshabibe1248b62015-08-20 17:21:55 -070019import com.google.common.base.Objects;
alshabibeadfc8e2015-08-18 15:40:46 -070020
alshabibbc371962015-07-09 22:26:21 -070021/**
22 * Representation of an operation on the meter table.
23 */
24public class MeterOperation {
25
alshabibeadfc8e2015-08-18 15:40:46 -070026
alshabibbc371962015-07-09 22:26:21 -070027 /**
28 * Tyoe of meter operation.
29 */
30 public enum Type {
31 ADD,
32 REMOVE,
33 MODIFY
34 }
35
36 private final Meter meter;
37 private final Type type;
38
39
alshabibe1248b62015-08-20 17:21:55 -070040 public MeterOperation(Meter meter, Type type) {
alshabibbc371962015-07-09 22:26:21 -070041 this.meter = meter;
42 this.type = type;
43 }
44
45 /**
46 * Returns the type of operation.
47 *
48 * @return type
49 */
50 public Type type() {
51 return type;
52 }
53
54 /**
55 * Returns the meter.
56 *
57 * @return a meter
58 */
59 public Meter meter() {
60 return meter;
61 }
62
alshabibbc371962015-07-09 22:26:21 -070063 @Override
64 public String toString() {
65 return MoreObjects.toStringHelper(this)
66 .add("meter", meter)
67 .add("type", type)
68 .toString();
69 }
alshabibe1248b62015-08-20 17:21:55 -070070
71 @Override
72 public boolean equals(Object o) {
73 if (this == o) {
74 return true;
75 }
76 if (o == null || getClass() != o.getClass()) {
77 return false;
78 }
79 MeterOperation that = (MeterOperation) o;
80 return Objects.equal(meter, that.meter) &&
81 Objects.equal(type, that.type);
82 }
83
84 @Override
85 public int hashCode() {
86 return Objects.hashCode(meter, type);
87 }
alshabibbc371962015-07-09 22:26:21 -070088}