//:: # Copyright 2013, Big Switch Networks, Inc.
//:: #
//:: # LoxiGen is licensed under the Eclipse Public License, version 1.0 (EPL), with
//:: # the following special exception:
//:: #
//:: # LOXI Exception
//:: #
//:: # As a special exception to the terms of the EPL, you may distribute libraries
//:: # generated by LoxiGen (LoxiGen Libraries) under the terms of your choice, provided
//:: # that copyright and licensing notices generated by LoxiGen are not altered or removed
//:: # from the LoxiGen Libraries and the notice provided below is (i) included in
//:: # the LoxiGen Libraries, if distributed in source code form and (ii) included in any
//:: # documentation for the LoxiGen Libraries, if distributed in binary form.
//:: #
//:: # Notice: "Copyright 2013, Big Switch Networks, Inc. This library was generated by the LoxiGen Compiler."
//:: #
//:: # You may not use this file except in compliance with the EPL or LOXI Exception. You may obtain
//:: # a copy of the EPL at:
//:: #
//:: # http::: #www.eclipse.org/legal/epl-v10.html
//:: #
//:: # Unless required by applicable law or agreed to in writing, software
//:: # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
//:: # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
//:: # EPL for the specific language governing permissions and limitations
//:: # under the EPL.
//::
//:: import itertools
//:: include('_copyright.java')

//:: include('_autogen.java')

package org.projectfloodlight.openflow.protocol;

//:: include("_imports.java")

public final class OFFactories {

    private static final GenericReader GENERIC_READER = new GenericReader();

    public static OFFactory getFactory(OFVersion version) {
        switch(version) {
            //:: for v in versions:
            case ${v.constant_version}:
                return org.projectfloodlight.openflow.protocol.ver${v.dotless_version}.OFFactoryVer${v.dotless_version}.INSTANCE;
            //:: #endfor
            default:
                throw new IllegalArgumentException("Unknown version: "+version);
            }
    }

    private static class GenericReader implements OFMessageReader<OFMessage> {
        public OFMessage readFrom(ByteBuf bb) throws OFParseError {
            if(!bb.isReadable())
                return null;
            short wireVersion = U8.f(bb.getByte(bb.readerIndex()));
            OFFactory factory;
            switch (wireVersion) {
            //:: for v in versions:
            case ${v.int_version}:
                factory = org.projectfloodlight.openflow.protocol.ver${v.dotless_version}.OFFactoryVer${v.dotless_version}.INSTANCE;
                break;
            //:: #endfor
            default:
                throw new IllegalArgumentException("Unknown wire version: " + wireVersion);
            }
            return factory.getReader().readFrom(bb);
        }
    }

    public static OFMessageReader<OFMessage> getGenericReader() {
        return GENERIC_READER;
    }
}
