All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.openlineage.sql.ColumnMeta Maven / Gradle / Ivy

There is a newer version: 1.26.0
Show newest version
/*
/* Copyright 2018-2024 contributors to the OpenLineage project
/* SPDX-License-Identifier: Apache-2.0
*/

package io.openlineage.sql;

import java.util.Optional;
import org.apache.commons.lang3.builder.HashCodeBuilder;

public class ColumnMeta {
  private final Optional origin; // nullable
  private final String name;

  public ColumnMeta(DbTableMeta origin, String name) {
    this.origin = Optional.ofNullable(origin);
    this.name = name;
  }

  public Optional origin() {
    return origin;
  }

  public String name() {
    return name;
  }

  @Override
  public String toString() {
    return String.format(
        "{\"origin\": %s, \"name\": \"%s\"}",
        origin.isPresent() ? origin.get().toString() : "\"unknown\"", name);
  }

  @Override
  public boolean equals(Object o) {
    if (o == this) {
      return true;
    }

    if (!(o instanceof ColumnMeta)) {
      return false;
    }

    ColumnMeta other = (ColumnMeta) o;
    return other.origin().equals(origin()) && other.name.equals(name);
  }

  @Override
  public int hashCode() {
    return new HashCodeBuilder().append(origin).append(name).toHashCode();
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy