/*
 * Copyright 2019-present Facebook, 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 com.facebook.buck.core.model;

import com.google.common.base.Preconditions;
import java.util.Objects;
import java.util.Optional;

/** Type-safe wrapper for a target output label */
public class OutputLabel implements Comparable<OutputLabel> {
  public static final OutputLabel DEFAULT = new OutputLabel();

  private final String label;

  private OutputLabel() {
    label = "";
  }

  public OutputLabel(String label) {
    Preconditions.checkArgument(!label.isEmpty());
    this.label = label;
  }

  @Override
  public String toString() {
    return label.isEmpty() ? "<default>" : label;
  }

  public Optional<String> getLabel() {
    return label.isEmpty() ? Optional.empty() : Optional.of(label);
  }

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

  @Override
  public int hashCode() {
    return Objects.hash(label);
  }

  @Override
  public int compareTo(OutputLabel o) {
    return this.label.compareTo(o.label);
  }
}

@@ -740,16 +740,19 @@
 al;%0A%0A/**
+%0A *
  Type-sa
@@ -791,73 +791,1372 @@
 abel
- */%0Apublic class OutputLabel implements Comparable%3COutputLabel%3E %7B
+.%0A *%0A * %3Cp%3EA build target can return different outputs groups, with each output group potentially%0A * containing zero or more outputs. A target output label is used to refer to a particular output%0A * group in a target.%0A *%0A * %3Cp%3EWith providers, the output label maps to named output groups in %7B@link%0A * com.facebook.buck.core.rules.providers.lib.DefaultInfo%7D. With the old action graph, each rule%0A * should maintain an internal mapping of output labels to output groups.%0A *%0A * %3Cp%3EA %7B@link #DEFAULT%7D output label is provided when the user has not specified a named output%0A * label in a build target. For example, %22//foo:bar%22 would be associated with the default output%0A * label, whereas %22//foo:bar%5Bbaz%5D would be associated with the named label %22baz%22.%0A */%0Apublic class OutputLabel implements Comparable%3COutputLabel%3E %7B%0A%0A  /**%0A   * Label denoting the default output group rather than a named output group.%0A   *%0A   * %3Cp%3EWith providers, this would be the default outputs from %7B@link%0A   * com.facebook.buck.core.rules.providers.lib.DefaultInfo%7D. The default outputs can be the set of%0A   * all possible outputs, a subset of all possible outputs, or an empty output group.%0A   *%0A   * %3Cp%3EWith the old action graph, this would be rule-dependent depending on how the rule implements%0A   * %7B@link com.facebook.buck.core.rules.attr.HasMultipleOutputs#getSourcePathToOutput()%7D.%0A   */
 %0A  p

Add more documentation to OutputLabel