Example #1
0
  @Override
  public Project registerFacet(final Facet facet) {
    if (facet == null) {
      throw new IllegalArgumentException(
          "Attempted to register 'null' as a Facet; Facets cannot be null.");
    }

    if (facet.getDependencies() != null) {
      for (Class<? extends Facet> type : facet.getDependencies()) {
        if (!hasFacet(type)) {
          throw new IllegalStateException(
              "Attempting to register a Facet that has missing dependencies: ["
                  + facet.getClass().getSimpleName()
                  + " requires -> "
                  + type.getSimpleName()
                  + "]");
        }
      }
    }

    facet.init(this);
    if (facet.isInstalled() && !hasFacet(facet.getClass())) {
      facets.add(facet);
    }
    return this;
  }
Example #2
0
 @Override
 public Project installFacet(final Facet facet) {
   facet.init(this);
   if (!facet.isInstalled() && !hasFacet(facet.getClass())) {
     facet.install();
     facets.add(facet);
   } else if (!hasFacet(facet.getClass())) {
     registerFacet(facet);
   }
   return this;
 }