Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 1 | /** |
| 2 | * Copyright 2011, Big Switch Networks, Inc. |
| 3 | * Originally created by David Erickson & Rob Sherwood, Stanford University |
| 4 | * |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 6 | * not use this file except in compliance with the License. You may obtain |
| 7 | * a copy of the License at |
| 8 | * |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 14 | * License for the specific language governing permissions and limitations |
| 15 | * under the License. |
| 16 | **/ |
| 17 | |
| 18 | package org.openflow.protocol.vendor; |
| 19 | |
| 20 | import org.openflow.protocol.Instantiable; |
| 21 | |
| 22 | /** |
| 23 | * Class that represents a specific vendor data type format in an |
| 24 | * OFVendor message. Typically the vendor data will begin with an integer |
| 25 | * code that determines the format of the rest of the data, but this |
| 26 | * class does not assume that. It's basically just a holder for an |
| 27 | * instantiator of the appropriate subclass of OFVendorData. |
| 28 | * |
| 29 | * @author Rob Vaterlaus (rob.vaterlaus@bigswitch.com) |
| 30 | */ |
| 31 | public class OFVendorDataType { |
| 32 | |
| 33 | /** |
| 34 | * Object that instantiates the subclass of OFVendorData |
| 35 | * associated with this data type. |
| 36 | */ |
| 37 | protected Instantiable<OFVendorData> instantiable; |
| 38 | |
| 39 | /** |
| 40 | * Construct an empty vendor data type. |
| 41 | */ |
| 42 | public OFVendorDataType() { |
| 43 | super(); |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * Construct a vendor data type with the specified instantiable. |
| 48 | * @param instantiable object that creates the subclass of OFVendorData |
| 49 | * associated with this data type. |
| 50 | */ |
| 51 | public OFVendorDataType(Instantiable<OFVendorData> instantiable) { |
| 52 | this.instantiable = instantiable; |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * Returns a new instance of a subclass of OFVendorData associated with |
| 57 | * this OFVendorDataType. |
| 58 | * |
| 59 | * @return the new object |
| 60 | */ |
| 61 | public OFVendorData newInstance() { |
| 62 | return instantiable.instantiate(); |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * @return the instantiable |
| 67 | */ |
| 68 | public Instantiable<OFVendorData> getInstantiable() { |
| 69 | return instantiable; |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * @param instantiable the instantiable to set |
| 74 | */ |
| 75 | public void setInstantiable(Instantiable<OFVendorData> instantiable) { |
| 76 | this.instantiable = instantiable; |
| 77 | } |
| 78 | |
| 79 | } |