Thomas Vachuska
Committed by Gerrit Code Review

Defining notion of a projectable entity.

Opened up DefaultDriverHandler to accept arbitrary DriverData.

Added clarifying documentation to DriverData.

Change-Id: Ic96251703bf0461caef4f3950658e2073d889653
...@@ -25,7 +25,7 @@ import static com.google.common.base.MoreObjects.toStringHelper; ...@@ -25,7 +25,7 @@ import static com.google.common.base.MoreObjects.toStringHelper;
25 */ 25 */
26 public class DefaultDriverHandler implements DriverHandler { 26 public class DefaultDriverHandler implements DriverHandler {
27 27
28 - private final DefaultDriverData data; 28 + private final DriverData data;
29 29
30 // Reference to service directory to provide run-time context. 30 // Reference to service directory to provide run-time context.
31 protected static ServiceDirectory serviceDirectory = new DefaultServiceDirectory(); 31 protected static ServiceDirectory serviceDirectory = new DefaultServiceDirectory();
...@@ -35,7 +35,7 @@ public class DefaultDriverHandler implements DriverHandler { ...@@ -35,7 +35,7 @@ public class DefaultDriverHandler implements DriverHandler {
35 * 35 *
36 * @param data driver data to attach 36 * @param data driver data to attach
37 */ 37 */
38 - public DefaultDriverHandler(DefaultDriverData data) { 38 + public DefaultDriverHandler(DriverData data) {
39 this.data = data; 39 this.data = data;
40 } 40 }
41 41
......
...@@ -21,6 +21,10 @@ import org.onosproject.net.MutableAnnotations; ...@@ -21,6 +21,10 @@ import org.onosproject.net.MutableAnnotations;
21 /** 21 /**
22 * Container for data about a device. Data is stored using 22 * Container for data about a device. Data is stored using
23 * {@link org.onosproject.net.MutableAnnotations}. 23 * {@link org.onosproject.net.MutableAnnotations}.
24 + *
25 + * Note that only derivatives of {@link HandlerBehaviour} can expect mutability
26 + * from the backing driver data instance; other behaviours must rely on
27 + * immutable {@link org.onosproject.net.Annotations} only.
24 */ 28 */
25 public interface DriverData extends MutableAnnotations { 29 public interface DriverData extends MutableAnnotations {
26 30
......
1 +/*
2 + * Copyright 2014-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 +
17 +package org.onosproject.net.driver;
18 +
19 +import com.google.common.annotations.Beta;
20 +
21 +/**
22 + * Abstraction of an entity capable of being projected as another entity.
23 + */
24 +@Beta
25 +public interface Projectable {
26 +
27 + /**
28 + * Returns the specified projection of this entity if such projection
29 + * is supported.
30 + *
31 + * @param projectionClass requested projection class
32 + * @param <B> type of behaviour
33 + * @return projection instance or null if requested projection is not supported
34 + */
35 + <B extends Behaviour> B as(Class<B> projectionClass);
36 +
37 + /**
38 + * Returns true if this entity is capable of being projected as the
39 + * specified class.
40 + *
41 + * @param projectionClass projection class
42 + * @param <B> type of behaviour
43 + * @return true if the requested projection is supported
44 + */
45 + <B extends Behaviour> boolean is(Class<B> projectionClass);
46 +
47 +}