Allow any hello mesage and extend hello support for v1.4, v1.5
[openflowjava.git] / openflow-protocol-impl / src / main / java / org / opendaylight / openflowjava / protocol / impl / util / VersionAssignableFactory.java
1 /*
2  * Copyright (c) 2016 Pantheon Technologies s.r.o. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.openflowjava.protocol.impl.util;
10
11 import javax.annotation.Nonnull;
12
13 /**
14  * Abstract factory class to support OF protocol version assigning and reading.
15  */
16 public abstract class VersionAssignableFactory {
17     private Short version;
18
19     /**
20      * @param version OpenFlow protocol version
21      */
22     public void assignVersion(@Nonnull final Short version) {
23         if (this.version == null) {
24             this.version = version;
25         } else {
26             throw new IllegalStateException("Version already assigned: " + this.version);
27         }
28     }
29
30     /**
31      * @return OpenFlow protocol version
32      */
33     protected Short getVersion() {
34         return this.version;
35     }
36 }