Fix javadoc warnings
[netconf.git] / restconf / restconf-nb-rfc8040 / src / main / java / org / opendaylight / restconf / nb / rfc8040 / streams / websockets / WebSocketConfiguration.java
1 /*
2  * Copyright © 2019 FRINX s.r.o. 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.restconf.nb.rfc8040.streams.websockets;
10
11 import com.google.common.base.Preconditions;
12
13 /**
14  * Web-socket configuration holder and verifier.
15  */
16 public class WebSocketConfiguration {
17
18     private static final int MAX_FRAGMENT_LENGTH = 65535;
19
20     private final int maximumFragmentLength;
21     private final int idleTimeout;
22     private final int heartbeatInterval;
23
24     /**
25      * Creation of the web-socket configuration holder with verification of input parameters.
26      *
27      * @param maximumFragmentLength Maximum web-socket fragment length in number of Unicode code units (characters)
28      *                              (exceeded message length leads to fragmentation of messages).
29      * @param idleTimeout           Maximum idle time of web-socket session before the session is closed (milliseconds).
30      * @param heartbeatInterval     Interval in milliseconds between sending of ping control frames.
31      */
32     public WebSocketConfiguration(int maximumFragmentLength, int idleTimeout, int heartbeatInterval) {
33         Preconditions.checkArgument(idleTimeout > 0, "Idle timeout must be specified by positive value.");
34         Preconditions.checkArgument(maximumFragmentLength >= 0 && maximumFragmentLength < MAX_FRAGMENT_LENGTH,
35                 "Maximum fragment length must be disabled (0) or specified by positive value "
36                         + "less than 64 KB.");
37         Preconditions.checkArgument(heartbeatInterval >= 0, "Heartbeat ping interval must be "
38                 + "disabled (0) or specified by positive value.");
39
40         this.maximumFragmentLength = maximumFragmentLength;
41         this.idleTimeout = idleTimeout;
42         this.heartbeatInterval = heartbeatInterval;
43     }
44
45     public int getMaximumFragmentLength() {
46         return maximumFragmentLength;
47     }
48
49     public int getIdleTimeout() {
50         return idleTimeout;
51     }
52
53     public int getHeartbeatInterval() {
54         return heartbeatInterval;
55     }
56 }