/
AmqpBridgeModelFactory.java
101 lines (90 loc) · 4.08 KB
/
AmqpBridgeModelFactory.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*
* Copyright (c) 2017 Bosch Software Innovations GmbH.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/org/documents/epl-2.0/index.php
*
* Contributors:
* Bosch Software Innovations GmbH - initial contribution
*/
package org.eclipse.ditto.model.amqpbridge;
import java.util.Map;
import java.util.Set;
import javax.annotation.concurrent.Immutable;
import org.eclipse.ditto.json.JsonObject;
import org.eclipse.ditto.model.base.auth.AuthorizationSubject;
/**
* Factory to create new {@link AmqpConnection} instances.
*/
@Immutable
public final class AmqpBridgeModelFactory {
private AmqpBridgeModelFactory() {
throw new AssertionError();
}
/**
* Returns a new {@code AmqpConnection} with all required fields set, optional fields are set to defaults.
*
* @param id the connection identifier.
* @param connectionType the connection type
* @param uri the connection uri.
* @param authorizationSubject the connection authorization subject.
* @param sources the connection sources.
* @return the ImmutableConnection.
* @throws NullPointerException if any argument is {@code null}.
*/
public static AmqpConnection newConnection(final String id,
final ConnectionType connectionType, final String uri,
final AuthorizationSubject authorizationSubject, final Set<String> sources) {
return ImmutableAmqpConnection.of(id, connectionType, uri, authorizationSubject, sources);
}
/**
* Returns a new {@code AmqpConnectionBuilder} with the required fields set.
*
* @param id the connection identifier.
* @param connectionType the connection type
* @param uri the connection uri.
* @param authorizationSubject the connection authorization subject.
* @param sources the connection sources.
* @return the AmqpConnectionBuilder.
* @throws NullPointerException if any argument is {@code null}.
*/
public static AmqpConnectionBuilder newConnectionBuilder(final String id,
final ConnectionType connectionType, final String uri,
final AuthorizationSubject authorizationSubject, final Set<String> sources) {
return ImmutableAmqpConnectionBuilder.of(id, connectionType, uri, authorizationSubject, sources);
}
/**
* Creates a new {@code Connection} object from the specified JSON object.
*
* @param jsonObject a JSON object which provides the data for the Connection to be created.
* @return a new Connection which is initialised with the extracted data from {@code jsonObject}.
* @throws NullPointerException if {@code jsonObject} is {@code null}.
* @throws org.eclipse.ditto.json.JsonParseException if {@code jsonObject} is not an appropriate JSON object.
*/
public static AmqpConnection connectionFromJson(final JsonObject jsonObject) {
return ImmutableAmqpConnection.fromJson(jsonObject);
}
/**
* Returns a new {@code MappingContext}.
*
* @return
* @throws NullPointerException if any argument is {@code null}.
*/
public static MappingContext newMappingContext(final String contentType, final String mappingEngine,
final Map<String, String> options) {
return ImmutableMappingContext.of(contentType, mappingEngine, options);
}
/**
* Creates a new {@code MappingContext} object from the specified JSON object.
*
* @param jsonObject a JSON object which provides the data for the MappingContext to be created.
* @return a new MappingContext which is initialised with the extracted data from {@code jsonObject}.
* @throws NullPointerException if {@code jsonObject} is {@code null}.
* @throws org.eclipse.ditto.json.JsonParseException if {@code jsonObject} is not an appropriate JSON object.
*/
public static MappingContext mappingContextFromJson(final JsonObject jsonObject) {
return ImmutableMappingContext.fromJson(jsonObject);
}
}