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

com.scalar.db.sql.Join Maven / Gradle / Ivy

There is a newer version: 3.14.0
Show newest version
package com.scalar.db.sql;

import com.google.common.base.MoreObjects;
import com.google.common.collect.ImmutableList;
import java.util.Objects;
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;

@Immutable
public class Join {

  public final JoinType joinType;
  public final TableRef table;
  public final String alias;
  public final ImmutableList joinPredicates;

  private Join(
      JoinType joinType,
      TableRef table,
      @Nullable String alias,
      ImmutableList joinPredicates) {
    this.joinType = Objects.requireNonNull(joinType);
    this.table = Objects.requireNonNull(table);
    this.alias = alias;
    this.joinPredicates = Objects.requireNonNull(joinPredicates);
  }

  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (!(o instanceof Join)) {
      return false;
    }
    Join join = (Join) o;
    return joinType == join.joinType
        && Objects.equals(table, join.table)
        && Objects.equals(alias, join.alias)
        && Objects.equals(joinPredicates, join.joinPredicates);
  }

  @Override
  public int hashCode() {
    return Objects.hash(joinType, table, alias, joinPredicates);
  }

  @Override
  public String toString() {
    return MoreObjects.toStringHelper(this)
        .add("joinType", joinType)
        .add("table", table)
        .add("alias", alias)
        .add("joinPredicates", joinPredicates)
        .toString();
  }

  public static Join create(
      JoinType joinType,
      TableRef table,
      @Nullable String alias,
      ImmutableList joinPredicates) {
    return new Join(joinType, table, alias, joinPredicates);
  }

  public enum JoinType {
    INNER_JOIN,
    LEFT_OUTER_JOIN,
    RIGHT_OUTER_JOIN,
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy