private static <T extends Facet> T getFacet(Class<T> facetType, FacetHolder... holders) {
   for (FacetHolder holder : holders) {
     if (holder == null) {
       continue;
     }
     final T facet = holder.getFacet(facetType);
     if (facet != null) {
       return facet;
     }
   }
   return null;
 }
  public static PublishedActionFacet create(
      final Action action, final IsisConfiguration configuration, final FacetHolder holder) {

    final Publishing publishing = action != null ? action.publishing() : Publishing.AS_CONFIGURED;

    switch (publishing) {
      case AS_CONFIGURED:
        final PublishActionsConfiguration setting =
            PublishActionsConfiguration.parse(configuration);
        switch (setting) {
          case NONE:
            return null;
          case IGNORE_SAFE:
            final ActionSemanticsFacet actionSemanticsFacet =
                holder.getFacet(ActionSemanticsFacet.class);
            if (actionSemanticsFacet == null) {
              throw new IllegalStateException("Require ActionSemanticsFacet in order to process");
            }

            if (actionSemanticsFacet.value().isSafeInNature()) {
              return null;
            }
            // else fall through
          default:
            final PublishingPayloadFactoryForAction publishingPayloadFactory =
                newPayloadFactory(action);
            return action != null
                ? new PublishedActionFacetForActionAnnotation(publishingPayloadFactory, holder)
                : new PublishedActionFacetFromConfiguration(publishingPayloadFactory, holder);
        }
      case DISABLED:
        return null;
      case ENABLED:
        return new PublishedActionFacetForActionAnnotation(newPayloadFactory(action), holder);
    }
    return null;
  }
 @Override
 public void removeFacet(Class<? extends Facet> facetType) {
   facetHolder.removeFacet(facetType);
 }
 @Override
 public void removeFacet(Facet facet) {
   facetHolder.removeFacet(facet);
 }
 @Override
 public void addFacet(MultiTypedFacet facet) {
   facetHolder.addFacet(facet);
 }
 @Override
 public void addFacet(Facet facet) {
   facetHolder.addFacet(facet);
 }
 @Override
 public List<Facet> getFacets(Filter<Facet> filter) {
   return facetHolder.getFacets(filter);
 }
 @Override
 public boolean containsDoOpFacet(java.lang.Class<? extends Facet> facetType) {
   return facetHolder.containsDoOpFacet(facetType);
 }
 @Override
 public boolean containsFacet(Class<? extends Facet> facetType) {
   return facetHolder.containsFacet(facetType);
 }
 @Override
 public <T extends Facet> T getFacet(Class<T> cls) {
   return facetHolder.getFacet(cls);
 }
 @Override
 public Class<? extends Facet>[] getFacetTypes() {
   return facetHolder.getFacetTypes();
 }
Exemple #12
0
 static boolean isRequired(final FacetHolder facetHolder) {
   final MandatoryFacet mandatoryFacet = facetHolder.getFacet(MandatoryFacet.class);
   final boolean required = mandatoryFacet != null && !mandatoryFacet.isInvertedSemantics();
   return required;
 }
Exemple #13
0
 @Override
 public <T extends Facet> T getFacet(final ScalarModel scalarModel, final Class<T> facetType) {
   final FacetHolder facetHolder = scalarModel.getParameterMemento().getActionParameter();
   return facetHolder.getFacet(facetType);
 }
Exemple #14
0
 @Override
 public <T extends Facet> T getFacet(final ScalarModel scalarModel, final Class<T> facetType) {
   final FacetHolder facetHolder = scalarModel.getPropertyMemento().getProperty();
   return facetHolder.getFacet(facetType);
 }
 private boolean isAlwaysHidden(final FacetHolder holder) {
   final HiddenFacet hiddenFacet = holder.getFacet(HiddenFacet.class);
   return hiddenFacet != null
       && hiddenFacet.when() == When.ALWAYS
       && hiddenFacet.where() == Where.ANYWHERE;
 }