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

com.autonomousapps.model.ProjectAdvice.kt Maven / Gradle / Ivy

There is a newer version: 2.6.1
Show newest version
// Copyright (c) 2024. Tony Robalik.
// SPDX-License-Identifier: Apache-2.0
package com.autonomousapps.model

import com.autonomousapps.internal.utils.LexicographicIterableComparator
import com.squareup.moshi.JsonClass

/** Collection of all advice for a single project, across all variants. */
@JsonClass(generateAdapter = false)
data class ProjectAdvice(
  val projectPath: String,
  val dependencyAdvice: Set = emptySet(),
  val pluginAdvice: Set = emptySet(),
  val moduleAdvice: Set = emptySet(),
  val warning: Warning = Warning.empty(),
  /** True if there is any advice in a category for which the user has declared they want the build to fail. */
  val shouldFail: Boolean = false
) : Comparable {

  fun isEmpty(): Boolean = dependencyAdvice.isEmpty() && pluginAdvice.isEmpty() && warning.isEmpty()
  fun isNotEmpty(): Boolean = !isEmpty()

  override fun compareTo(other: ProjectAdvice): Int {
    return compareBy(ProjectAdvice::projectPath)
      .thenBy(LexicographicIterableComparator()) { it.dependencyAdvice }
      .thenBy(LexicographicIterableComparator()) { it.pluginAdvice }
      .thenBy(LexicographicIterableComparator()) { it.moduleAdvice }
      .thenBy(ProjectAdvice::warning)
      .thenBy(ProjectAdvice::shouldFail)
      .compare(this, other)
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy