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

com.jetbrains.plugin.structure.ide.layout.LoadingResults.kt Maven / Gradle / Ivy

package com.jetbrains.plugin.structure.ide.layout

import com.jetbrains.plugin.structure.ide.layout.PluginWithArtifactPathResult.Failure
import com.jetbrains.plugin.structure.ide.layout.PluginWithArtifactPathResult.Success
import com.jetbrains.plugin.structure.intellij.plugin.IdePlugin

internal class LoadingResults() {
  constructor(results: List) : this() {
    add(results)
  }

  private val _successes = mutableListOf()
  private val _failures = mutableListOf()

  val successes: List
    get() = _successes

  val failures: List
    get() = _failures

  val successfulPlugins: List
    get() = successes.map { it.plugin }

  fun add(results: List) {
    val (successes, failures) = results.partition {
      it is Success
    }
    _successes += successes.map { it as Success }
    _failures += failures.map { it as Failure }
  }

  fun add(result: PluginWithArtifactPathResult): LoadingResults {
    when (result) {
      is Success -> _successes += result
      is Failure -> _failures += result
    }
    return this
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy