Skip to content

Extend Attribute annotation to support boolean attributes #1850

@stefanuebe

Description

@stefanuebe

The @Attribute annotation allows TB elements to specify the query by specific attributes. Unfortunately it does not support boolean attributes, like for instance has-value on fields or similar. Setting "true" or the attribute name itself as value does not work.

Therefore the request is, that there should be a new parameter value "booleanValue", that has a type of a new enum BooleanAttributeValue.

That enum consists of the items

  • UNUSED
  • TRUE
  • FALSE

The value UNUSED is the default and marks that parameter as "ignore me", like the other parameter defaults do. Using TRUE or FALSE instead will mark the parameter as set and thus ignore the other parameters value and contains.

Depending on TRUE or FALSE the respective attribute will be interpreted as "is explicitly set" or "is explicitly not set", like ElementQuery#withAttribute(String) / withoutAttribute(String) would do.

A use case we have: find all grids, that are not tree grids and vice versa. (but I assume, there are many many more out there)

@Attribute(name = "hierarchical", booleanValue = TRUE) 
public class CustomGridElement extends GridElement
@Attribute(name = "hierarchical", booleanValue = FALSE) 
public class CustomTreeGridElement extends TreeGridElement

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    Done / Pending Release

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions