Fix checkstyle complains
[bgpcep.git] / bgp / rib-impl / src / main / java / org / opendaylight / protocol / bgp / rib / impl / BGPHandlerFactory.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. 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 package org.opendaylight.protocol.bgp.rib.impl;
9
10
11 import static java.util.Objects.requireNonNull;
12
13 import io.netty.channel.ChannelHandler;
14 import io.netty.channel.ChannelOutboundHandler;
15
16 import org.opendaylight.protocol.bgp.parser.spi.MessageRegistry;
17
18 /**
19  * BGP specific factory for protocol inbound/outbound handlers.
20  */
21 public class BGPHandlerFactory {
22     private final ChannelOutboundHandler encoder;
23     private final MessageRegistry registry;
24
25     public BGPHandlerFactory(final MessageRegistry registry) {
26         this.registry = requireNonNull(registry);
27         this.encoder = new BGPMessageToByteEncoder(registry);
28     }
29
30     public ChannelHandler[] getEncoders() {
31         return new ChannelHandler[] { this.encoder, };
32     }
33
34     public ChannelHandler[] getDecoders() {
35         return new ChannelHandler[] { BGPMessageHeaderDecoder.getBGPMessageHeaderDecoder(),
36                 new BGPByteToMessageDecoder(this.registry), };
37     }
38 }