@@ -68,7 +68,7 @@ public static CommandPublishingFacet create(
6868
6969 return propertyIfAny
7070 .filter (property -> property .commandPublishing () != Publishing .NOT_SPECIFIED )
71- .map (property -> {
71+ .< CommandPublishingFacet > map (property -> {
7272 Publishing publishing = property .commandPublishing ();
7373
7474 var processorClass = property .commandDtoProcessor ();
@@ -78,64 +78,54 @@ public static CommandPublishingFacet create(
7878 publishing = Publishing .ENABLED ;
7979 }
8080
81- switch (publishing ) {
82- case AS_CONFIGURED :
83- switch (publishingPolicy ) {
84- case NONE :
85- return (CommandPublishingFacet )new CommandPublishingFacetForPropertyAnnotationAsConfigured .None (holder , servicesInjector );
86- case ALL :
87- return new CommandPublishingFacetForPropertyAnnotationAsConfigured .All (holder , servicesInjector );
88- default :
89- throw new IllegalStateException (String .format ("configured property.commandpublishing policy '%s' not recognised" , publishingPolicy ));
90- }
91- case DISABLED :
92- return new CommandPublishingFacetForPropertyAnnotation .Disabled (processor , holder , servicesInjector );
93- case ENABLED :
94- return new CommandPublishingFacetForPropertyAnnotation .Enabled (processor , holder , servicesInjector );
95- default :
96- throw new IllegalStateException (String .format ("@Property#commandPublishing '%s' not recognised" , publishing ));
97- }
81+ return switch (publishing ) {
82+ case AS_CONFIGURED -> switch (publishingPolicy ) {
83+ case NONE -> new CommandPublishingFacetForPropertyAnnotationAsConfigured .None (holder , servicesInjector );
84+ case ALL -> new CommandPublishingFacetForPropertyAnnotationAsConfigured .All (holder , servicesInjector );
85+ default -> throw new IllegalStateException (
86+ String .format ("configured property.commandpublishing policy '%s' not recognised" , publishingPolicy ));
87+ };
88+ case DISABLED -> new CommandPublishingFacetForPropertyAnnotation .Disabled (processor , holder , servicesInjector );
89+ case ENABLED , ENABLED_FOR_UPDATES_ONLY -> new CommandPublishingFacetForPropertyAnnotation .Enabled (processor , holder , servicesInjector );
90+ default -> throw new IllegalStateException (
91+ String .format ("@Property#commandPublishing '%s' not recognised" , publishing ));
92+ };
9893 })
9994 .orElseGet (() -> {
10095 // there is no publishing facet from either @Action or @Property, so use the appropriate configuration to install a default
101- if (representsProperty (holder )) {
96+ if (representsProperty (holder ))
10297 // we are dealing with a property
103- switch (publishingPolicy ) {
104- case NONE :
105- return new CommandPublishingFacetForPropertyFromConfiguration .None (holder , servicesInjector );
106- case ALL :
107- return new CommandPublishingFacetForPropertyFromConfiguration .All (holder , servicesInjector );
108- default :
109- throw new IllegalStateException (String .format ("configured property.commandPublishing policy '%s' not recognised" , publishingPolicy ));
110- }
111- } else {
98+ return switch (publishingPolicy ) {
99+ case NONE -> new CommandPublishingFacetForPropertyFromConfiguration .None (holder , servicesInjector );
100+ case ALL -> new CommandPublishingFacetForPropertyFromConfiguration .All (holder , servicesInjector );
101+ default -> throw new IllegalStateException (String .format ("configured property.commandPublishing policy '%s' not recognised" , publishingPolicy ));
102+ };
103+ else {
112104 // we are dealing with an action
113105 var actionPublishingPolicy = ActionConfigOptions .actionCommandPublishingPolicy (configuration );
114- switch (actionPublishingPolicy ) {
115- case NONE :
116- return new CommandPublishingFacetForActionFromConfiguration .None (holder , servicesInjector );
117- case IGNORE_QUERY_ONLY :
118- case IGNORE_SAFE :
119- return Facets .hasSafeSemantics (holder )
120- ? new CommandPublishingFacetForActionFromConfiguration .IgnoreSafe (holder , servicesInjector )
121- : new CommandPublishingFacetForActionFromConfiguration .IgnoreSafeYetNot (holder , servicesInjector );
122- case ALL :
123- return new CommandPublishingFacetForActionFromConfiguration .All (holder , servicesInjector );
124- default :
125- throw new IllegalStateException (String .format ("configured action.commandPublishing policy '%s' not recognised" , actionPublishingPolicy ));
126- }
106+ return switch (actionPublishingPolicy ) {
107+ case NONE -> new CommandPublishingFacetForActionFromConfiguration .None (holder , servicesInjector );
108+ case IGNORE_QUERY_ONLY , IGNORE_SAFE -> Facets .hasSafeSemantics (holder )
109+ ? new CommandPublishingFacetForActionFromConfiguration .IgnoreSafe (holder , servicesInjector )
110+ : new CommandPublishingFacetForActionFromConfiguration .IgnoreSafeYetNot (holder , servicesInjector );
111+ case ALL -> new CommandPublishingFacetForActionFromConfiguration .All (holder , servicesInjector );
112+ default -> throw new IllegalStateException (String .format ("configured action.commandPublishing policy '%s' not recognised" , actionPublishingPolicy ));
113+ };
127114 }
128115 });
116+
129117 }
130118
131119 private static boolean representsProperty (final FacetHolder holder ) {
132120 // a property
133- if (holder instanceof TypedFacetHolder && ((TypedFacetHolder )holder ).featureType () == FeatureType .PROPERTY ) {
121+ if (holder instanceof TypedFacetHolder typedFacetHolder
122+ && typedFacetHolder .featureType () == FeatureType .PROPERTY )
134123 return true ;
135- }
136124 // or a mixin
137- return holder .containsFacet (ContributingFacet .class ) &&
138- holder .getFacet (ContributingFacet .class ).contributed () == MixinFacet .Contributing .AS_PROPERTY ;
125+ return holder .lookupFacet (ContributingFacet .class )
126+ .map (ContributingFacet ::contributed )
127+ .map (MixinFacet .Contributing .AS_PROPERTY ::equals )
128+ .orElse (false );
139129 }
140130
141131 CommandPublishingFacetForPropertyAnnotation (
0 commit comments