Your browser was unable to load all of the resources. They may have been blocked by your firewall, proxy or browser configuration.
Press Ctrl+F5 or Ctrl+Shift+R to have your browser try again.

Type is not supported with Set or Map #3754

SVMC_DPI ·

When I try to develop a plugin has UI with type of property to show to user input data: Set or Map<String,String>
and got error with log:

Caused by: com.pmease.quickbuild.QuickbuildException: Type is not supported. (class:com.pmease.quickbuild.plugin.webhook.settings.WebHookSetting, property:customData)
at com.pmease.quickbuild.web.component.editor.EditContext.init(EditContext.java:114)

I need I save a set of key/value or Set of property but I can't
Could you help me?

  • solved #4
  • replies 3
  • views 2160
  • stars 0
robinshen ADMIN ·

Set or Map is not supported. You may define a class say property with name and value, and use List to define a list of properties.

SVMC_DPI ·

Because I need a set of key/value. if use List, the data may be duplicated.
Do you have any solution to validate data (notice duplicate key)

robinshen ADMIN ·

To check duplications and other validations, have your class implementing Validatable interface like below:

import com.pmease.quickbuild.validation.Validatable;

@Editable
MyBean implements Validatable {

  private List<Property> properties;

  public List<Property> getProperties() {
    return properties;
  }

  public void setProperties(List<Property> properties) {
    this.properties = properties;
  }

  @Override
  public void validate(Set<String> properties, ErrorContext errorContext) {
    Set<String> keys = new HashSet<>();
    for (Property property: getProperties()) {
      if (!keys.add(property.getName()) {
        errorContext.setError("properties", "duplicate key found: " + property.getName());
      }
    }
  }
}