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.");
    }

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

    facet.setProject(this);
    if (facet.isInstalled() && !hasFacet(facet.getClass())) {
      facets.add(facet);
    }
    return this;
  }
Example #2
0
 private void performInstallation(final Facet facet) {
   if (facet.install()) {
     facets.add(facet);
   } else {
     throw new ProjectModelException(
         "Could not complete installation of "
             + "facet: ["
             + ConstraintInspector.getName(facet.getClass())
             + "]. "
             + "Installation was aborted by the Facet during installation.");
   }
 }