Commit 9899cab4 authored by René Schöne's avatar René Schöne
Browse files

Merge branch 'master' into 19-poc-use-mustache-as-template-engine

parents 15c33065 52785f37
......@@ -141,16 +141,23 @@ aspect AspectGeneration {
sb.append(ind(indent + 1)).append(preemptiveReturnStatement()).append("\n");
sb.append(ind(indent)).append("}\n");
if (!getAlwaysApply()) {
sb.append(ind(indent)).append("if (").append(preemptiveExpectedValue());
if (getToken().isPrimitiveType()) {
sb.append(" == ").append(inputVariableName);
} else if (effectiveMappings().get(effectiveMappings().size() - 1).isDefaultMappingDefinition()) {
sb.append(" != null && ").append(preemptiveExpectedValue()).append(".equals(")
.append(inputVariableName).append(")");
MappingDefinition lastMapping = effectiveMappings().get(effectiveMappings().size() - 1);
sb.append(ind(indent)).append("if (");
if (lastMapping.getToType().isArray()) {
sb.append("java.util.Arrays.equals(").append(preemptiveExpectedValue())
.append(", ").append(inputVariableName).append(")");
} else {
sb.append(" != null ? ").append(preemptiveExpectedValue()).append(".equals(")
.append(inputVariableName).append(")").append(" : ")
.append(inputVariableName).append(" == null");
sb.append(preemptiveExpectedValue());
if (getToken().isPrimitiveType() && lastMapping.getToType().isPrimitiveType()) {
sb.append(" == ").append(inputVariableName);
} else if (lastMapping.isDefaultMappingDefinition()) {
sb.append(" != null && ").append(preemptiveExpectedValue()).append(".equals(")
.append(inputVariableName).append(")");
} else {
sb.append(" != null ? ").append(preemptiveExpectedValue()).append(".equals(")
.append(inputVariableName).append(")").append(" : ")
.append(inputVariableName).append(" == null");
}
}
sb.append(") { ").append(preemptiveReturnStatement()).append(" }\n");
}
......
......@@ -151,6 +151,12 @@ aspect Mappings {
default: return false;
}
}
syn boolean MappingDefinitionType.isPrimitiveType() = false;
eq JavaMappingDefinitionType.isPrimitiveType() = getType().isPrimitiveType();
// --- isArray ---
syn boolean MappingDefinitionType.isArray() = false;
eq JavaArrayMappingDefinitionType.isArray() = true;
// --- suitableDefaultMapping ---
syn DefaultMappingDefinition UpdateDefinition.suitableDefaultMapping();
......
......@@ -231,8 +231,16 @@ public class MqttUpdater {
}
public void publish(String topic, byte[] bytes) {
publish(topic, bytes, false);
}
public void publish(String topic, byte[] bytes, boolean retain) {
publish(topic, bytes, this.qos, retain);
}
public void publish(String topic, byte[] bytes, org.fusesource.mqtt.client.QoS qos, boolean retain) {
connection.getDispatchQueue().execute(() -> {
connection.publish(topic, bytes, qos, false, new org.fusesource.mqtt.client.Callback<Void>() {
connection.publish(topic, bytes, qos, retain, new org.fusesource.mqtt.client.Callback<Void>() {
@Override
public void onSuccess(Void value) {
logger.debug("Published some bytes to {}", topic);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment