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

Reversion: Tech debt: Revert to KCQL java tests #1235

Merged
merged 1 commit into from
May 29, 2024
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

public class Field {

Expand All @@ -34,10 +35,10 @@ public Field(String name, FieldType fieldType, List<String> parents) {
}

public Field(String name, String alias, FieldType fieldType, List<String> parents) {
if (name == null || name.trim().length() == 0) {
if (name == null || name.trim().isEmpty()) {
throw new IllegalArgumentException(String.format("field is not valid:<%s>", String.valueOf(name)));
}
if (alias == null || alias.trim().length() == 0) {
if (alias == null || alias.trim().isEmpty()) {
throw new IllegalArgumentException(String.format("alias is not valid:<%s>", String.valueOf(alias)));
}
this.name = name;
Expand Down Expand Up @@ -77,6 +78,33 @@ public String toString() {
return sb.toString();
}

@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;

Field field = (Field) o;

if (!Objects.equals(name, field.name))
return false;
if (!Objects.equals(alias, field.alias))
return false;
if (fieldType != field.fieldType)
return false;
return Objects.equals(parentFields, field.parentFields);
}

@Override
public int hashCode() {
int result = name != null ? name.hashCode() : 0;
result = 31 * result + (alias != null ? alias.hashCode() : 0);
result = 31 * result + (fieldType != null ? fieldType.hashCode() : 0);
result = 31 * result + (parentFields != null ? parentFields.hashCode() : 0);
return result;
}

public static Field from(String name, List<String> parents) {
return from(name, null, parents);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
* Parsing support for Kafka Connect Query Language.
Expand Down Expand Up @@ -248,6 +249,14 @@ public Iterator<String> getPartitionBy() {
return partitionBy.iterator();
}

public Set<String> getPartitionByAsSet() {
Iterator<String> partitionByIter = getPartitionBy();
return Stream.generate(() -> null)
.takeWhile(x -> partitionByIter.hasNext())
.map(n -> partitionByIter.next())
.collect(Collectors.toSet());
}

public List<Tag> getTags() {
return tags;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
package io.lenses.kcql;

import java.util.Objects;

public class Tag {

private final String key;
Expand Down Expand Up @@ -50,4 +52,28 @@ public enum TagType {
ALIAS,
CONSTANT
}

@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;

Tag tag = (Tag) o;

if (!Objects.equals(key, tag.key))
return false;
if (!Objects.equals(value, tag.value))
return false;
return type == tag.type;
}

@Override
public int hashCode() {
int result = key != null ? key.hashCode() : 0;
result = 31 * result + (value != null ? value.hashCode() : 0);
result = 31 * result + (type != null ? type.hashCode() : 0);
return result;
}
}
Loading
Loading