Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replaced HashSet with LinkedHashSet for deterministic ordering in IsIn #322

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions core/src/main/java/uk/gov/gchq/koryphe/impl/predicate/IsIn.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@

import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.Set;

/**
Expand All @@ -47,11 +48,12 @@ public IsIn() {
}

public IsIn(final Collection<Object> controlData) {
this.allowedValues = new HashSet<>(controlData);
this.allowedValues = new LinkedHashSet<>(controlData);
}

public IsIn(final Object... controlData) {
this.allowedValues = Sets.newHashSet(controlData);
this.allowedValues = Sets.newLinkedHashSet();
Collections.addAll(this.allowedValues, controlData);
}

@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.WRAPPER_OBJECT)
Expand All @@ -64,9 +66,9 @@ public Object[] getAllowedValuesArray() {
@JsonProperty("values")
public void setAllowedValues(final Object[] allowedValuesArray) {
if (null != allowedValuesArray) {
allowedValues = new HashSet<>(Arrays.asList(allowedValuesArray));
allowedValues = new LinkedHashSet<>(Arrays.asList(allowedValuesArray));
} else {
allowedValues = new HashSet<>(0);
allowedValues = new LinkedHashSet<>(0);
}
}

Expand Down