com.hivemq.client.internal.mqtt.message.MqttCommonReasonCode Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hivemq-mqtt-client Show documentation
Show all versions of hivemq-mqtt-client Show documentation
HiveMQ MQTT Client is an MQTT 5.0 and MQTT 3.1.1 compatible and feature-rich high-performance Java client library with different API flavours and backpressure support
/*
* Copyright 2018 dc-square and the HiveMQ MQTT Client Project
*
* 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.client.internal.mqtt.message;
import com.hivemq.client.internal.util.collections.ImmutableList;
import com.hivemq.client.mqtt.mqtt5.message.Mqtt5ReasonCode;
import org.jetbrains.annotations.NotNull;
/**
* MQTT Reason Codes that are used in 2 ore more MQTT packets according to the MQTT 5 specification.
*
* @author Silvio Giebl
*/
public enum MqttCommonReasonCode implements Mqtt5ReasonCode {
SUCCESS(0x00),
NO_MATCHING_SUBSCRIBERS(0x10),
UNSPECIFIED_ERROR(0x80),
MALFORMED_PACKET(0x81),
PROTOCOL_ERROR(0x82),
IMPLEMENTATION_SPECIFIC_ERROR(0x83),
NOT_AUTHORIZED(0x87),
SERVER_BUSY(0x89),
BAD_AUTHENTICATION_METHOD(0x8C),
TOPIC_FILTER_INVALID(0x8F),
TOPIC_NAME_INVALID(0x90),
PACKET_IDENTIFIER_IN_USE(0x91),
PACKET_IDENTIFIER_NOT_FOUND(0x92),
PACKET_TOO_LARGE(0x95),
QUOTA_EXCEEDED(0x97),
PAYLOAD_FORMAT_INVALID(0x99),
RETAIN_NOT_SUPPORTED(0x9A),
QOS_NOT_SUPPORTED(0x9B),
USE_ANOTHER_SERVER(0x9C),
SERVER_MOVED(0x9D),
SHARED_SUBSCRIPTIONS_NOT_SUPPORTED(0x9E),
CONNECTION_RATE_EXCEEDED(0x9F),
SUBSCRIPTION_IDENTIFIERS_NOT_SUPPORTED(0xA1),
WILDCARD_SUBSCRIPTIONS_NOT_SUPPORTED(0xA2);
private final int code;
MqttCommonReasonCode(final int code) {
this.code = code;
}
/**
* @return the byte code of this Reason Code.
*/
@Override
public int getCode() {
return code;
}
public static boolean allErrors(final @NotNull ImmutableList extends Mqtt5ReasonCode> reasonCodes) {
//noinspection ForLoopReplaceableByForEach
for (int i = 0; i < reasonCodes.size(); i++) {
if (!reasonCodes.get(i).isError()) {
return false;
}
}
return true;
}
}