Skip to content

Commit

Permalink
[ZEE-6082] Add type and source to DataProduct
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurtemple committed Nov 28, 2024
1 parent 569ece8 commit f84f3c9
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 3 deletions.
70 changes: 68 additions & 2 deletions src/main/java/zeenea/connector/dataproduct/DataProduct.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.*;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import zeenea.connector.Item;
import zeenea.connector.dataset.Dataset;
import zeenea.connector.exception.ExceptionUtils;
Expand All @@ -10,6 +11,12 @@
/** Represents a data product which is a specialized type of Item. */
public final class DataProduct extends Item {

/** Enum representing the type of the data product. */
public enum Type {
Custom,
DataProductSpecificationDotCom
}

/** The list of input ports for the data product. */
@NotNull private final List<InputPort> inputPorts;

Expand All @@ -19,6 +26,13 @@ public final class DataProduct extends Item {
/** The list of internal components for the data product. */
@NotNull private final List<Item> internalComponents;

/** The type of the data product. */
@NotNull private final Type type;

/** The source of the data product. */
@Nullable
private final String source;

/**
* Constructs a DataProduct instance using the provided builder.
*
Expand All @@ -32,6 +46,8 @@ private DataProduct(Builder builder) {
inputPorts = List.copyOf(builder.inputPorts);
outputPorts = List.copyOf(builder.outputPorts);
internalComponents = List.copyOf(builder.internalComponents);
type = Optional.ofNullable(builder.type).orElse(Type.Custom);
source = builder.source;
}

/**
Expand Down Expand Up @@ -61,6 +77,24 @@ private DataProduct(Builder builder) {
return internalComponents;
}

/**
* Gets the type of the data product.
*
* @return the type of the data product
*/
public @NotNull Type getType() {
return type;
}

/**
* Gets the source of the data product.
*
* @return the source of the data product
*/
public @Nullable String getSource() {
return source;
}

/**
* Checks if this DataProduct is equal to another object.
*
Expand All @@ -74,7 +108,9 @@ public boolean equals(Object o) {
DataProduct that = (DataProduct) o;
return Objects.equals(inputPorts, that.inputPorts)
&& Objects.equals(outputPorts, that.outputPorts)
&& Objects.equals(internalComponents, that.internalComponents);
&& Objects.equals(internalComponents, that.internalComponents)
&& Objects.equals(type, that.type)
&& Objects.equals(source, that.source);
}

/**
Expand All @@ -84,7 +120,7 @@ public boolean equals(Object o) {
*/
@Override
public int hashCode() {
return Objects.hash(inputPorts, outputPorts, internalComponents);
return Objects.hash(inputPorts, outputPorts, internalComponents, type, source);
}

/**
Expand All @@ -111,6 +147,10 @@ public String toString() {
+ internalComponents
+ ", outputPorts="
+ outputPorts
+ ", type="
+ type
+ ", source="
+ source
+ "}";
}

Expand Down Expand Up @@ -151,6 +191,10 @@ public static class Builder extends Item.Builder<DataProduct, Builder> {

private List<Item> internalComponents = Collections.emptyList();

private Type type;

private String source;

/**
* Set a collection of input ports to the data product.
*
Expand Down Expand Up @@ -217,6 +261,28 @@ public Builder internalComponents(Item... items) {
return this;
}

/**
* Sets the type of the data product.
*
* @param type the type of the data product
* @return the builder instance
*/
public Builder type(@NotNull Type type) {
this.type = type;
return this;
}

/**
* Sets the source of the data product.
*
* @param source the source of the data product
* @return the builder instance
*/
public Builder source(@Nullable String source) {
this.source = source;
return this;
}

/**
* Builds and returns a DataProduct instance.
*
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.1.0
2.2.0

0 comments on commit f84f3c9

Please sign in to comment.