blob: 247ccecf1e872cf566cebe8750e969710d64ac84 [file] [log] [blame]
Thomas Vachuskaa8f4e7d2015-01-08 17:31:55 -08001/*
2 * Copyright 2015 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 */
16package org.onosproject.net.driver;
17
18import static com.google.common.base.MoreObjects.toStringHelper;
19
20/**
21 * Default implementation of driver handler.
22 */
23public class DefaultDriverHandler implements DriverHandler {
24
25 private final DefaultDriverData data;
26
27 /**
28 * Creates new driver handler with the attached driver data.
29 *
30 * @param data driver data to attach
31 */
32 public DefaultDriverHandler(DefaultDriverData data) {
33 this.data = data;
34 }
35
36 @Override
37 public DriverData data() {
38 return data;
39 }
40
41 @Override
42 public <T extends Behaviour> T behaviour(Class<T> behaviourClass) {
43 return data.type().createBehaviour(this.data, behaviourClass, true);
44 }
45
46 @Override
47 public String toString() {
48 return toStringHelper(this)
49 .add("data", data)
50 .toString();
51 }
52
53}