Add transport-{api,tcp}
[netconf.git] / transport / transport-api / src / main / java / org / opendaylight / netconf / transport / api / TransportChannel.java
1 /*
2  * Copyright (c) 2022 PANTHEON.tech, 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 package org.opendaylight.netconf.transport.api;
9
10 import com.google.common.base.MoreObjects;
11 import com.google.common.base.MoreObjects.ToStringHelper;
12 import io.netty.channel.Channel;
13 import org.eclipse.jdt.annotation.NonNull;
14
15 /**
16  * A transport-level session. This concept is bound to a {@link Channel} for now, so as to enforce type-safety. It acts
17  * as a meeting point between a logical NETCONF session and the underlying transport.
18  */
19 public abstract class TransportChannel {
20     /**
21      * Return the underlying Netty channel.
22      *
23      * @return Netty channel
24      */
25     public abstract @NonNull Channel channel();
26
27     @Override
28     public final int hashCode() {
29         return super.hashCode();
30     }
31
32     @Override
33     public final boolean equals(final Object obj) {
34         return super.equals(obj);
35     }
36
37     @Override
38     public final String toString() {
39         return addToStringAttributes(MoreObjects.toStringHelper(this).omitNullValues()).toString();
40     }
41
42     protected ToStringHelper addToStringAttributes(final ToStringHelper helper) {
43         return helper.add("channel", channel());
44     }
45 }