Skip to content

Commit

Permalink
Minor adaptions after review
Browse files Browse the repository at this point in the history
* Add missing since annotation in javadoc
* Made class PipelineElementResolved immutable (as stated by its
  annotation) and added a test for this

Signed-off-by: Yannic Klem <Yannic.Klem@bosch.io>
  • Loading branch information
Yannic92 committed Mar 4, 2022
1 parent 7f266d6 commit c96812d
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
Expand Up @@ -63,6 +63,7 @@ public interface PipelineElement extends Iterable<String> {
*
* @param pipelineElement the pipeline element to concatenate
* @return the pipeline element which holds the concatenated resolved vales.
* @since 2.4.0
*/
PipelineElement concat(PipelineElement pipelineElement);

Expand Down
Expand Up @@ -12,7 +12,9 @@
*/
package org.eclipse.ditto.placeholders;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
Expand All @@ -31,10 +33,10 @@
@Immutable
final class PipelineElementResolved implements PipelineElement {

private final Collection<String> values;
private final List<String> values;

private PipelineElementResolved(final Collection<String> values) {
this.values = ConditionChecker.checkNotEmpty(values, "values");
this.values = Collections.unmodifiableList(new ArrayList<>(ConditionChecker.checkNotEmpty(values, "values")));
}

static PipelineElement of(final Collection<String> values) {
Expand Down
@@ -0,0 +1,27 @@
/*
* Copyright (c) 2022 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.placeholders;

import static org.mutabilitydetector.unittesting.MutabilityAssert.assertInstancesOf;
import static org.mutabilitydetector.unittesting.MutabilityMatchers.areImmutable;

import org.junit.Test;

public final class PipelineElementResolvedTest {

@Test
public void assertImmutability() {
assertInstancesOf(PipelineElementResolved.class, areImmutable());
}

}

0 comments on commit c96812d

Please sign in to comment.