-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Port Mqtt3ConnectRestrictions from master
with the following changes: - new package names - replace annotations DoNotImplement and CheckReturnValue - add missing Range annotations - rename fluent restrictions() -> restrictionsWith()
- Loading branch information
Showing
9 changed files
with
249 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
src/main/java/com/hivemq/mqtt/client2/mqtt3/message/connect/Mqtt3ConnectRestrictions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* Copyright 2018-present HiveMQ and the HiveMQ Community | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* 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 License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.hivemq.mqtt.client2.mqtt3.message.connect; | ||
|
||
import com.hivemq.mqtt.client2.internal.datatypes.MqttVariableByteInteger; | ||
import com.hivemq.mqtt.client2.internal.message.connect.MqttConnectRestrictionsBuilder; | ||
import com.hivemq.mqtt.client2.internal.util.UnsignedDataTypes; | ||
import org.jetbrains.annotations.ApiStatus; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Range; | ||
|
||
/** | ||
* Restrictions applied by the client in an {@link Mqtt3Connect MQTT 3 Connect message}. | ||
* | ||
* @author Yannick Weber | ||
* @since 1.3 | ||
*/ | ||
@ApiStatus.NonExtendable | ||
public interface Mqtt3ConnectRestrictions { | ||
|
||
/** | ||
* Creates a builder for Connect restrictions. | ||
* | ||
* @return the created builder. | ||
*/ | ||
static @NotNull Mqtt3ConnectRestrictionsBuilder builder() { | ||
return new MqttConnectRestrictionsBuilder.Default(); | ||
} | ||
|
||
/** | ||
* Returns the maximum amount of not acknowledged publishes with QoS 1 or 2 the client sends to the server | ||
* concurrently. The default is | ||
* {@link com.hivemq.mqtt.client2.mqtt5.message.connect.Mqtt5ConnectRestrictions#DEFAULT_SEND_MAXIMUM | ||
* DEFAULT_SEND_MAXIMUM}. | ||
* | ||
* @return the maximum amount of not acknowledged publishes with QoS 1 or 2 the client sends to the server | ||
* concurrently. | ||
*/ | ||
@Range(from = 1, to = UnsignedDataTypes.UNSIGNED_SHORT_MAX_VALUE) int getSendMaximum(); | ||
|
||
/** | ||
* Returns the maximum packet size the client sends to the server. The default is | ||
* {@link com.hivemq.mqtt.client2.mqtt5.message.connect.Mqtt5ConnectRestrictions#DEFAULT_SEND_MAXIMUM_PACKET_SIZE | ||
* DEFAULT_SEND_MAXIMUM_PACKET_SIZE}. | ||
* | ||
* @return the maximum packet size the client sends to the server. | ||
*/ | ||
@Range(from = 1, to = MqttVariableByteInteger.MAXIMUM_PACKET_SIZE_LIMIT) int getSendMaximumPacketSize(); | ||
|
||
/** | ||
* Creates a builder for extending this Connect restrictions. | ||
* | ||
* @return the created builder. | ||
*/ | ||
@NotNull Mqtt3ConnectRestrictionsBuilder extend(); | ||
} |
56 changes: 56 additions & 0 deletions
56
...n/java/com/hivemq/mqtt/client2/mqtt3/message/connect/Mqtt3ConnectRestrictionsBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright 2018-present HiveMQ and the HiveMQ Community | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* 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 License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.hivemq.mqtt.client2.mqtt3.message.connect; | ||
|
||
import org.jetbrains.annotations.ApiStatus; | ||
import org.jetbrains.annotations.CheckReturnValue; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
/** | ||
* Builder for {@link Mqtt3ConnectRestrictions}. | ||
* | ||
* @author Yannick Weber | ||
* @since 1.3 | ||
*/ | ||
@ApiStatus.NonExtendable | ||
public interface Mqtt3ConnectRestrictionsBuilder | ||
extends Mqtt3ConnectRestrictionsBuilderBase<Mqtt3ConnectRestrictionsBuilder> { | ||
|
||
/** | ||
* Builds the {@link Mqtt3ConnectRestrictions}. | ||
* | ||
* @return the built {@link Mqtt3ConnectRestrictions}. | ||
*/ | ||
@CheckReturnValue | ||
@NotNull Mqtt3ConnectRestrictions build(); | ||
|
||
/** | ||
* Builder for {@link Mqtt3ConnectRestrictions} that are applied to a parent. | ||
* | ||
* @param <P> the type of the result when the built {@link Mqtt3ConnectRestrictions} are applied to the parent. | ||
*/ | ||
@ApiStatus.NonExtendable | ||
interface Nested<P> extends Mqtt3ConnectRestrictionsBuilderBase<Nested<P>> { | ||
|
||
/** | ||
* Builds the {@link Mqtt3ConnectRestrictions} and applies them to the parent. | ||
* | ||
* @return the result when the built {@link Mqtt3ConnectRestrictions} are applied to the parent. | ||
*/ | ||
@NotNull P applyRestrictions(); | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
...va/com/hivemq/mqtt/client2/mqtt3/message/connect/Mqtt3ConnectRestrictionsBuilderBase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright 2018-present HiveMQ and the HiveMQ Community | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* 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 License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.hivemq.mqtt.client2.mqtt3.message.connect; | ||
|
||
import com.hivemq.mqtt.client2.internal.datatypes.MqttVariableByteInteger; | ||
import com.hivemq.mqtt.client2.internal.util.UnsignedDataTypes; | ||
import org.jetbrains.annotations.ApiStatus; | ||
import org.jetbrains.annotations.CheckReturnValue; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Range; | ||
|
||
/** | ||
* Builder base for {@link Mqtt3ConnectRestrictions}. | ||
* | ||
* @param <B> the type of the builder. | ||
* @author Yannick Weber | ||
* @since 1.3 | ||
*/ | ||
@ApiStatus.NonExtendable | ||
public interface Mqtt3ConnectRestrictionsBuilderBase<B extends Mqtt3ConnectRestrictionsBuilderBase<B>> { | ||
|
||
/** | ||
* Sets the {@link Mqtt3ConnectRestrictions#getSendMaximum() send maximum}. | ||
* <p> | ||
* The value must not be zero and must be in the range of an unsigned short: [1, 65_535]. | ||
* | ||
* @param receiveMaximum the send maximum. | ||
* @return the builder. | ||
*/ | ||
@CheckReturnValue | ||
@NotNull B sendMaximum(@Range(from = 1, to = UnsignedDataTypes.UNSIGNED_SHORT_MAX_VALUE) int receiveMaximum); | ||
|
||
/** | ||
* Sets the {@link Mqtt3ConnectRestrictions#getSendMaximumPacketSize() maximum packet size for sending}. | ||
* <p> | ||
* The value must not be zero and in the range: [1, 268_435_460]. | ||
* | ||
* @param maximumPacketSize the maximum packet size for sending. | ||
* @return the builder. | ||
*/ | ||
@CheckReturnValue | ||
@NotNull B sendMaximumPacketSize( | ||
@Range(from = 1, to = MqttVariableByteInteger.MAXIMUM_PACKET_SIZE_LIMIT) int maximumPacketSize); | ||
} |