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

com.danielsomerfield.cvecheck.gradle.handlers.buildRules.ListBackedBuildRules.groovy Maven / Gradle / Ivy

There is a newer version: 0.6.2-100
Show newest version
package com.danielsomerfield.cvecheck.gradle.handlers.buildRules

class ListBackedBuildRules implements BuildRules {
  private List addedRules = []
  private List defaultRules = []

  ListBackedBuildRules(List defaultRules = []) {
    this.defaultRules = defaultRules;
  }

  @Override
  void addBuildRule(final BuildRule rule) {
    addedRules.add(rule)
  }

  @Override
  public void each(Closure closure) {
    getRules().each closure
  }

  @Override
  public  Collection map(final Closure closure) {
    getRules().collect(closure)
  }

  @Override
  int size() {
    getRules().size()
  }

  BuildRule get(int index) {
    return getRules().get(index)
  }

  private List getRules() {
    addedRules.empty ? defaultRules : addedRules
  }

  @Override
  public String toString() {
    return "ListBackedBuildRules{" +
        "addedRules=" + addedRules +
        ", defaultRules=" + defaultRules +
        '}';
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy