Skip to content

Commit c949073

Browse files
committed
Cleanup - SStill W.I.P
Signed-off-by: Jem Day <[email protected]>
1 parent de2b76a commit c949073

27 files changed

+453
-99
lines changed

bindings/mqtt/core/src/main/java/io/cloudevents/mqtt/core/BaseMqttBinaryMessageReader.java

+20-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright 2018-Present The CloudEvents Authors
3+
* <p>
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* <p>
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
* <p>
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
117
package io.cloudevents.mqtt.core;
218

319
import io.cloudevents.SpecVersion;
@@ -25,9 +41,10 @@ public abstract class BaseMqttBinaryMessageReader extends BaseGenericBinaryMessa
2541

2642
/**
2743
* Initialise the binary message reader.
28-
* @param version The CloudEvent message version.
44+
*
45+
* @param version The CloudEvent message version.
2946
* @param contentType The assigned media content type.
30-
* @param payload The raw data payload from the MQTT message.
47+
* @param payload The raw data payload from the MQTT message.
3148
*/
3249
protected BaseMqttBinaryMessageReader(final SpecVersion version, final String contentType, final byte[] payload) {
3350
super(version, payload != null && payload.length > 0 ? BytesCloudEventData.wrap(payload) : null);
@@ -82,6 +99,7 @@ protected String toCloudEventsValue(Object value) {
8299

83100
/**
84101
* Visit each MQTT user-property and invoke the supplied function.
102+
*
85103
* @param fn The function to invoke for each MQTT User property.
86104
*/
87105
protected abstract void forEachUserProperty(BiConsumer<String, Object> fn);

bindings/mqtt/core/src/main/java/io/cloudevents/mqtt/core/MqttUtils.java

+21-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright 2018-Present The CloudEvents Authors
3+
* <p>
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* <p>
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
* <p>
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
117
package io.cloudevents.mqtt.core;
218

319
import io.cloudevents.core.format.EventFormat;
@@ -8,24 +24,26 @@
824
*/
925
public class MqttUtils {
1026

11-
private MqttUtils() {}
27+
private static final String DEFAULT_FORMAT = "application/cloudevents+json";
1228

13-
private static final String DEFAULT_FORMAT = "application/cloudevents+json";
29+
private MqttUtils() {
30+
}
1431

1532
/**
1633
* Obtain the {@link EventFormat} to use when working with MQTT V3
1734
* messages.
1835
*
1936
* @return An event format.
2037
*/
21-
public static EventFormat getDefaultEventFormat () {
38+
public static EventFormat getDefaultEventFormat() {
2239

2340
return EventFormatProvider.getInstance().resolveFormat(DEFAULT_FORMAT);
2441

2542
}
2643

2744
/**
2845
* Get the default content type to assume for MQTT messages.
46+
*
2947
* @return A Content-Type
3048
*/
3149
public static final String getDefaultContentType() {

bindings/mqtt/hivemq/src/main/java/io/cloudevents/mqtt/hivemq/BinaryMessageReader.java

+16
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright 2018-Present The CloudEvents Authors
3+
* <p>
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* <p>
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
* <p>
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
117
package io.cloudevents.mqtt.hivemq;
218

319
import com.hivemq.client.mqtt.mqtt5.message.publish.Mqtt5Publish;

bindings/mqtt/hivemq/src/main/java/io/cloudevents/mqtt/hivemq/MqttMessageFactory.java

+18-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright 2018-Present The CloudEvents Authors
3+
* <p>
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* <p>
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
* <p>
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
117
package io.cloudevents.mqtt.hivemq;
218

319
import com.hivemq.client.mqtt.datatypes.MqttUtf8String;
@@ -20,7 +36,6 @@
2036
* A factory to obtain:
2137
* - {@link MessageReader} instances to read CloudEvents from MQTT messages.
2238
* - {@link MessageWriter} instances to write CloudEvents into MQTT messages.
23-
*
2439
*/
2540
public class MqttMessageFactory {
2641

@@ -74,7 +89,7 @@ public static MessageWriter createWriter(Mqtt5PublishBuilder.Complete builder) {
7489

7590
/**
7691
* Create a {@link MessageWriter} for an MQTT V3 Message.
77-
*
92+
* <p>
7893
* Only supports structured messages.
7994
*
8095
* @param builder {@link Mqtt3PublishBuilder.Complete}
@@ -89,6 +104,7 @@ public static MessageWriter createWriter(Mqtt3PublishBuilder.Complete builder) {
89104

90105
/**
91106
* Find the value of the CloudEvent 'specversion' in the MQTT V5 User Properties.
107+
*
92108
* @param message An MQTT message.
93109
* @return spec version attribute content.
94110
*/

bindings/mqtt/hivemq/src/main/java/io/cloudevents/mqtt/hivemq/V3MessageWriter.java

+20-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright 2018-Present The CloudEvents Authors
3+
* <p>
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* <p>
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
* <p>
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
117
package io.cloudevents.mqtt.hivemq;
218

319
import com.hivemq.client.mqtt.mqtt3.message.publish.Mqtt3PublishBuilder;
@@ -20,21 +36,21 @@ class V3MessageWriter implements MessageWriter<CloudEventWriter<Mqtt3PublishBuil
2036
@Override
2137
public CloudEventWriter<Mqtt3PublishBuilder> create(SpecVersion version) throws CloudEventRWException {
2238
// No-Op
23-
return null;
39+
throw CloudEventRWException.newOther("Internal Error");
2440
}
2541

2642
@Override
2743
public Mqtt3PublishBuilder setEvent(EventFormat format, byte[] value) throws CloudEventRWException {
2844
// No-Op
29-
return null;
45+
throw CloudEventRWException.newOther("Internal Error");
3046
}
3147

3248
@Override
3349
public Mqtt3PublishBuilder writeStructured(CloudEvent event, String format) {
34-
EventFormat eventFormat = EventFormatProvider.getInstance().resolveFormat(format);
50+
final EventFormat eventFormat = EventFormatProvider.getInstance().resolveFormat(format);
3551

3652
if (eventFormat != null) {
37-
return writeStructured(event, EventFormatProvider.getInstance().resolveFormat(format));
53+
return writeStructured(event, eventFormat);
3854
} else {
3955
throw CloudEventRWException.newOther("Unsupported Format: " + format);
4056
}

bindings/mqtt/hivemq/src/main/java/io/cloudevents/mqtt/hivemq/V5MessageWriter.java

+16
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright 2018-Present The CloudEvents Authors
3+
* <p>
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* <p>
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
* <p>
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
117
package io.cloudevents.mqtt.hivemq;
218

319
import com.hivemq.client.mqtt.mqtt5.message.publish.Mqtt5PublishBuilder;
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
/**
22
* This module implements the MQTT binding specification using the
33
* HiveMQ MQTT client library.
4-
*
4+
* <p>
55
* Use the {@link io.cloudevents.mqtt.hivemq.MqttMessageFactory} to obtain
66
* CloudEvent reader and writer instances.
7-
*
7+
* <p>
88
* Both V3 and V5 versions of MQTT are supported.
99
*
1010
* @since 2.5.0
11-
*
1211
*/
1312

1413
package io.cloudevents.mqtt.hivemq;

bindings/mqtt/hivemq/src/test/java/io/cloudevents/mqtt/hivemq/MqttMessageFactoryTest.java

+16
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright 2018-Present The CloudEvents Authors
3+
* <p>
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* <p>
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
* <p>
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
117
package io.cloudevents.mqtt.hivemq;
218

319
import com.hivemq.client.mqtt.mqtt3.message.publish.Mqtt3Publish;

bindings/mqtt/hivemq/src/test/java/io/cloudevents/mqtt/hivemq/V3MessageWriterTest.java

+16
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright 2018-Present The CloudEvents Authors
3+
* <p>
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* <p>
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
* <p>
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
117
package io.cloudevents.mqtt.hivemq;
218

319
import com.hivemq.client.mqtt.mqtt3.message.publish.Mqtt3Publish;

bindings/mqtt/hivemq/src/test/java/io/cloudevents/mqtt/hivemq/V3RoundTripTests.java

+16
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright 2018-Present The CloudEvents Authors
3+
* <p>
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* <p>
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
* <p>
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
117
package io.cloudevents.mqtt.hivemq;
218

319
import com.hivemq.client.mqtt.mqtt3.message.publish.Mqtt3Publish;

bindings/mqtt/hivemq/src/test/java/io/cloudevents/mqtt/hivemq/V5MessageWriterTest.java

+16
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright 2018-Present The CloudEvents Authors
3+
* <p>
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* <p>
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
* <p>
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
117
package io.cloudevents.mqtt.hivemq;
218

319
import com.hivemq.client.mqtt.mqtt5.datatypes.Mqtt5UserProperty;

bindings/mqtt/hivemq/src/test/java/io/cloudevents/mqtt/hivemq/V5RoundTripTests.java

+16
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright 2018-Present The CloudEvents Authors
3+
* <p>
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* <p>
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
* <p>
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
117
package io.cloudevents.mqtt.hivemq;
218

319
import com.hivemq.client.mqtt.mqtt5.message.publish.Mqtt5Publish;

bindings/mqtt/paho/src/main/java/io/cloudevents/mqtt/paho/BinaryMessageReader.java

+16
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright 2018-Present The CloudEvents Authors
3+
* <p>
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* <p>
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
* <p>
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
117
package io.cloudevents.mqtt.paho;
218

319
import io.cloudevents.SpecVersion;

bindings/mqtt/paho/src/main/java/io/cloudevents/mqtt/paho/PahoMessageUtils.java

+16
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright 2018-Present The CloudEvents Authors
3+
* <p>
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* <p>
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
* <p>
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
117
package io.cloudevents.mqtt.paho;
218

319
import org.eclipse.paho.mqttv5.common.MqttMessage;

0 commit comments

Comments
 (0)