Navigation Menu

Skip to content

Commit

Permalink
moved connectivity related placeholder classes out of placeholders mo…
Browse files Browse the repository at this point in the history
…del module

Signed-off-by: Thomas Jaeckle <thomas.jaeckle@bosch-si.com>
  • Loading branch information
thjaeckle committed Nov 12, 2019
1 parent 0a4a20c commit 30f41bf
Show file tree
Hide file tree
Showing 36 changed files with 114 additions and 92 deletions.
9 changes: 1 addition & 8 deletions model/connectivity/pom.xml
Expand Up @@ -39,7 +39,7 @@
</dependency>
<dependency>
<groupId>org.eclipse.ditto</groupId>
<artifactId>ditto-protocol-adapter</artifactId>
<artifactId>ditto-model-placeholders</artifactId>
</dependency>

<!-- ### Testing ### -->
Expand Down Expand Up @@ -91,13 +91,6 @@
<plugin>
<groupId>com.github.siom79.japicmp</groupId>
<artifactId>japicmp-maven-plugin</artifactId>
<configuration>
<parameter>
<excludes>
<exclude>org.eclipse.ditto.model.connectivity.ConnectionType</exclude>
</excludes>
</parameter>
</configuration>
</plugin>
</plugins>
</build>
Expand Down
Expand Up @@ -824,4 +824,11 @@ public static LogEntryBuilder newLogEntryBuilder(final String correlationId, fin
final LogType logType, final LogLevel logLevel, final String message) {
return ImmutableLogEntry.getBuilder(correlationId, timestamp, logCategory, logType, logLevel, message);
}

/**
* @return new instance of the {@link org.eclipse.ditto.model.connectivity.SourceAddressPlaceholder}
*/
public static SourceAddressPlaceholder newSourceAddressPlaceholder() {
return ImmutableSourceAddressPlaceholder.INSTANCE;
}
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017 Contributors to the Eclipse Foundation
* Copyright (c) 2019 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
Expand All @@ -10,9 +10,10 @@
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.eclipse.ditto.model.placeholders;
package org.eclipse.ditto.model.connectivity;

import org.eclipse.ditto.model.connectivity.Enforcement;
import org.eclipse.ditto.model.placeholders.Placeholder;
import org.eclipse.ditto.model.placeholders.PlaceholderFactory;

/**
* Factory class that creates instances of {@link EnforcementFilterFactory}s.
Expand All @@ -35,8 +36,8 @@ private static <I> EnforcementFilterFactory<I, CharSequence > newEnforcementFilt
}

/**
* Creates new instance of {@link EnforcementFilterFactory} that is preconfigured with a {@link ThingPlaceholder}
* for the filters.
* Creates new instance of {@link EnforcementFilterFactory} that is preconfigured with a
* {@link org.eclipse.ditto.model.placeholders.ThingPlaceholder} for the filters.
*
* @param <I> the type from which the input values are resolved
* @param enforcement the enforcement options
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017 Contributors to the Eclipse Foundation
* Copyright (c) 2019 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
Expand All @@ -10,7 +10,7 @@
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.eclipse.ditto.model.placeholders;
package org.eclipse.ditto.model.connectivity;

import org.eclipse.ditto.model.base.headers.DittoHeaders;

Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017 Contributors to the Eclipse Foundation
* Copyright (c) 2019 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
Expand All @@ -10,7 +10,7 @@
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.eclipse.ditto.model.placeholders;
package org.eclipse.ditto.model.connectivity;

/**
* Factory that creates {@link EnforcementFilter}s. As part of the creation the input value is resolved and can
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017 Contributors to the Eclipse Foundation
* Copyright (c) 2019 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
Expand All @@ -10,15 +10,15 @@
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.eclipse.ditto.model.placeholders;
package org.eclipse.ditto.model.connectivity;

import java.util.Objects;

import javax.annotation.concurrent.Immutable;

import org.eclipse.ditto.model.base.headers.DittoHeaders;
import org.eclipse.ditto.model.connectivity.ConnectionSignalIdEnforcementFailedException;
import org.eclipse.ditto.model.connectivity.Enforcement;
import org.eclipse.ditto.model.placeholders.Placeholder;
import org.eclipse.ditto.model.placeholders.PlaceholderFilter;

/**
* Immutable implementation of an {@link EnforcementFilter}.
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017 Contributors to the Eclipse Foundation
* Copyright (c) 2019 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
Expand All @@ -10,11 +10,13 @@
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.eclipse.ditto.model.placeholders;
package org.eclipse.ditto.model.connectivity;

import javax.annotation.concurrent.Immutable;

import org.eclipse.ditto.model.connectivity.Enforcement;
import org.eclipse.ditto.model.placeholders.Placeholder;
import org.eclipse.ditto.model.placeholders.PlaceholderFactory;
import org.eclipse.ditto.model.placeholders.PlaceholderFilter;

/**
* Factory that creates instances of EnforcementFilterFactory.
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017 Contributors to the Eclipse Foundation
* Copyright (c) 2019 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
Expand All @@ -10,14 +10,16 @@
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.eclipse.ditto.model.placeholders;
package org.eclipse.ditto.model.connectivity;

import java.util.Collections;
import java.util.List;
import java.util.Optional;

import javax.annotation.concurrent.Immutable;

import org.eclipse.ditto.model.placeholders.Expression;

/**
* Simple placeholder that currently only supports {@code {{ source:address }}} as a placeholder.
* In the context of an incoming MQTT message the placeholder is resolved with the message topic.
Expand All @@ -34,7 +36,7 @@ final class ImmutableSourceAddressPlaceholder implements SourceAddressPlaceholde
private static final String VALUE = "address";

private static final List<String> VALID_VALUES = Collections.unmodifiableList(
Collections.singletonList(PREFIX + Placeholder.SEPARATOR + VALUE));
Collections.singletonList(PREFIX + Expression.SEPARATOR + VALUE));

@Override
public String getPrefix() {
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017 Contributors to the Eclipse Foundation
* Copyright (c) 2019 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
Expand All @@ -10,9 +10,11 @@
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.eclipse.ditto.model.placeholders;
package org.eclipse.ditto.model.connectivity;


import org.eclipse.ditto.model.placeholders.Placeholder;

/**
* A {@link Placeholder} that requires a {@code String}
* (a {@link org.eclipse.ditto.model.connectivity.Source} {@code address}) to resolve its placeholders.
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017 Contributors to the Eclipse Foundation
* Copyright (c) 2019 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
Expand All @@ -10,16 +10,15 @@
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.eclipse.ditto.model.placeholders;
package org.eclipse.ditto.model.connectivity;

import java.util.HashMap;
import java.util.Map;

import org.eclipse.ditto.model.base.headers.DittoHeaders;
import org.eclipse.ditto.model.connectivity.ConnectionSignalIdEnforcementFailedException;
import org.eclipse.ditto.model.connectivity.ConnectivityModelFactory;
import org.eclipse.ditto.model.connectivity.Enforcement;
import org.eclipse.ditto.model.connectivity.UnresolvedPlaceholderException;
import org.eclipse.ditto.model.placeholders.Placeholder;
import org.eclipse.ditto.model.placeholders.PlaceholderFactory;
import org.eclipse.ditto.model.placeholders.UnresolvedPlaceholderException;
import org.eclipse.ditto.model.things.ThingId;
import org.junit.Test;
import org.mutabilitydetector.unittesting.AllowedReason;
Expand All @@ -29,7 +28,7 @@
import nl.jqno.equalsverifier.EqualsVerifier;

/**
* Tests {@link ImmutableEnforcementFilter}.
* Tests {@link org.eclipse.ditto.model.connectivity.ImmutableEnforcementFilter}.
*/
public class ImmutableEnforcementFilterTest {

Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017 Contributors to the Eclipse Foundation
* Copyright (c) 2019 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
Expand All @@ -10,7 +10,7 @@
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.eclipse.ditto.model.placeholders;
package org.eclipse.ditto.model.connectivity;

import static org.assertj.core.api.Assertions.assertThat;
import static org.mutabilitydetector.unittesting.MutabilityAssert.assertInstancesOf;
Expand All @@ -19,7 +19,7 @@
import org.junit.Test;

/**
* Tests {@link ImmutableSourceAddressPlaceholder}.
* Tests {@link org.eclipse.ditto.model.connectivity.ImmutableSourceAddressPlaceholder}.
*/
public class ImmutableSourceAddressPlaceholderTest {

Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017 Contributors to the Eclipse Foundation
* Copyright (c) 2019 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
Expand All @@ -10,12 +10,14 @@
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.eclipse.ditto.model.placeholders;
package org.eclipse.ditto.model.connectivity;

import java.util.Collections;
import java.util.List;
import java.util.Optional;

import org.eclipse.ditto.model.placeholders.Placeholder;

/**
* Simple placeholder for test purposes.
*/
Expand Down
2 changes: 1 addition & 1 deletion model/placeholders/pom.xml
Expand Up @@ -43,7 +43,7 @@
</dependency>
<dependency>
<groupId>org.eclipse.ditto</groupId>
<artifactId>ditto-model-connectivity</artifactId>
<artifactId>ditto-protocol-adapter</artifactId>
</dependency>

<!-- ### Testing ### -->
Expand Down
Expand Up @@ -42,7 +42,7 @@ public interface ExpressionResolver {
*
* @param pipelineExpression the pipeline expression.
* @return the pipeline element after evaluation.
* @throws org.eclipse.ditto.model.connectivity.UnresolvedPlaceholderException if not all placeholders were resolved
* @throws UnresolvedPlaceholderException if not all placeholders were resolved
*/
PipelineElement resolveAsPipelineElement(String pipelineExpression);

Expand Down
Expand Up @@ -30,7 +30,6 @@
import javax.annotation.concurrent.Immutable;

import org.eclipse.ditto.model.base.exceptions.DittoRuntimeException;
import org.eclipse.ditto.model.connectivity.UnresolvedPlaceholderException;

/**
* Immutable implementation of {@link ExpressionResolver} containing the logic of how an expression is resolved.
Expand Down
@@ -0,0 +1,26 @@
/*
* Copyright (c) 2019 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.eclipse.ditto.model.placeholders;

/**
* Aggregates all {@link org.eclipse.ditto.model.base.exceptions.DittoRuntimeException}s which are thrown in scope
* of placeholders.
*/
public interface PlaceholderException {

/**
* Error code prefix of errors thrown by the placeholder functionality.
*/
String ERROR_CODE_PREFIX = "placeholder" + ":";

}
Expand Up @@ -38,13 +38,6 @@ public static ThingPlaceholder newThingPlaceholder() {
return ImmutableThingPlaceholder.INSTANCE;
}

/**
* @return new instance of the {@link SourceAddressPlaceholder}
*/
public static SourceAddressPlaceholder newSourceAddressPlaceholder() {
return ImmutableSourceAddressPlaceholder.INSTANCE;
}

/**
* @return new instance of the {@link TopicPathPlaceholder}
*/
Expand Down
Expand Up @@ -29,7 +29,6 @@
import org.eclipse.ditto.model.base.auth.AuthorizationModelFactory;
import org.eclipse.ditto.model.base.auth.AuthorizationSubject;
import org.eclipse.ditto.model.base.common.Placeholders;
import org.eclipse.ditto.model.connectivity.UnresolvedPlaceholderException;
import org.eclipse.ditto.model.things.ThingId;

/**
Expand Down Expand Up @@ -112,7 +111,7 @@ private static String applyThingPlaceholder(final String address, final ThingId
* @param <T> the type of the placeholderSource
* @throws UnresolvedPlaceholderException if not all placeholders could be resolved
*/
static <T> String apply(final String template, final T placeholderSource, final Placeholder<T> placeholder) {
public static <T> String apply(final String template, final T placeholderSource, final Placeholder<T> placeholder) {
return apply(template, PlaceholderFactory.newExpressionResolver(placeholder, placeholderSource));
}

Expand Down

0 comments on commit 30f41bf

Please sign in to comment.