/*
 * Copyright © 2018 Cask Data, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */

package io.cdap.cdap.proto.metadata.lineage;

import io.cdap.cdap.api.annotation.Beta;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import javax.annotation.Nullable;

/**
 * Represents the lineage summary associated with the field of a dataset.
 *
 * In incoming direction, it consists of the datasets and their fields ({@link DatasetField}) that
 * this field originates from.
 *
 * In outgoing direction, it consists of the datasets and their fields ({@link DatasetField}) that
 * were computed from this field.
 */
@Beta
public class FieldLineageSummary {

  private final Set<DatasetField> incoming;
  private final Set<DatasetField> outgoing;

  public FieldLineageSummary(@Nullable Set<DatasetField> incoming,
      @Nullable Set<DatasetField> outgoing) {
    this.incoming = incoming == null ? null : Collections.unmodifiableSet(new HashSet<>(incoming));
    this.outgoing = outgoing == null ? null : Collections.unmodifiableSet(new HashSet<>(outgoing));
  }

  @Nullable
  public Set<DatasetField> getIncoming() {
    return incoming;
  }

  @Nullable
  public Set<DatasetField> getOutgoing() {
    return outgoing;
  }
}
