Annotation Interface FilterContent


@Target({METHOD,ANNOTATION_TYPE}) @Retention(RUNTIME) public @interface FilterContent
Declares that a method should be invoked to filter the visibility of an object for a specific User.

Filtering allows objects to dynamically adjust their exposed content based on who is viewing them. This is especially useful in projections, document models, or search results that may be shared with different roles.

Invocation: Filtering is applied by calling Fluxzero.filterContent(Object, User). Filtering is not automatic; it must be triggered explicitly.

Injection: The annotated method may accept the following parameters:

  • User – the current user performing the access
  • Root object – the top-level object being filtered (useful for context when filtering nested values)
Any other arguments will be ignored.

Return value: The method should return:

  • this – if the value is fully visible
  • a modified copy – if only a subset of the value should be shown
  • null – if the value should be completely hidden

Recursive filtering: Filtering is automatically applied to nested objects, collections, and maps. When filtering results in null for an item inside a collection or map:

  • The item is removed from a List
  • The key-value pair is removed from a Map

Example (filtering the object):


 @FilterContent
 public Order filter(User user) {
     return user.hasRole("admin") ? this : new Order(maskedFieldsOnly());
 }
 

Example (filtering a nested item with root injection):


 @FilterContent
 public LineItem filter(User user, Order root) {
     return root.isPublic() ? this : null;
 }
 
See Also: