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

com.google.cloud.tools.opensource.classpath.LinkageCheckReport Maven / Gradle / Ivy

/*
 * Copyright 2018 Google LLC.
 *
 * 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.google.cloud.tools.opensource.classpath;

import com.google.auto.value.AutoValue;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableList;

/**
 * The result of a linkage check.
 */
@AutoValue
public abstract class LinkageCheckReport {

  public abstract ImmutableList getJarLinkageReports();

  @VisibleForTesting
  public static LinkageCheckReport create(Iterable jarLinkageReports) {
    return new AutoValue_LinkageCheckReport(ImmutableList.copyOf(jarLinkageReports));
  }
  
  @Override
  public String toString() {
    StringBuilder builder = new StringBuilder();
    for (JarLinkageReport jarLinkageReport : getJarLinkageReports()) {
      if (jarLinkageReport.getCauseToSourceClassesSize() > 0) {
        builder.append(jarLinkageReport.toString());
        builder.append('\n');
      }
    }
    
    String result = builder.toString();
    if (result.isEmpty()) {
      return "No linkage errors\n";
    }
    return result;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy