/** * Return whether the given property name should be considered matching the candidate * configuration property, also taking into account the list of whitelist properties * (which are tested on their short name). */ static boolean isMatchingProperty(String propertyName, ConfigurationMetadataProperty property, List<ConfigurationMetadataProperty> whiteListedProps) { if (property.getId().equals(propertyName)) { return true; // For any prop } // Handle special case of short form for whitelist else { for (ConfigurationMetadataProperty white : whiteListedProps) { if (property.getId().equals(white.getId())) { // prop#equals() not implemented return property.getName().equals(propertyName); } } return false; } } }
@Override public List<ValueHint> generateValueHints(ConfigurationMetadataProperty property, ClassLoader classLoader) { return "java.lang.Boolean".equals(property.getType()) ? BOOLEANS : Collections.<ValueHint>emptyList(); }
private String niceDescription(ConfigurationMetadataProperty property) { return property.getDescription() == null ? "<documentation missing>" : property.getDescription(); }
@Override public int compare(ConfigurationMetadataProperty p1, ConfigurationMetadataProperty p2) { if (!sortDeprLast) { return p1.getId().compareTo(p2.getId()); } else { boolean d1 = p1.isDeprecated(); boolean d2 = p2.isDeprecated(); if (d1 && !d2) { return 1; } else if (d2 && !d1) { return -1; } else { return p1.getId().compareTo(p2.getId()); } } }
public ConfigurationMetadataSearchResult(final ConfigurationMetadataProperty prop, final CasConfigurationMetadataRepository repository) { try { setDefaultValue(prop.getDefaultValue()); setDeprecation(prop.getDeprecation()); setDescription(cleanUpDescription(prop.getDescription())); setShortDescription(cleanUpDescription(prop.getShortDescription())); setId(prop.getId()); setName(prop.getName()); setType(prop.getType()); setGroup(CasConfigurationMetadataRepository.getPropertyGroupId(prop)); setOrder(CasConfigurationMetadataRepository.isCasProperty(prop) ? Ordered.HIGHEST_PRECEDENCE : Ordered.LOWEST_PRECEDENCE); val valueHints = prop.getHints().getValueHints(); valueHints.forEach(hint -> { val values = CollectionUtils.toCollection(hint.getValue()); if (values.contains(RequiresModule.class.getName())) { setRequiredModule(hint.getDescription()); setRequiredModuleAutomated(values.contains(Boolean.TRUE)); } if (values.contains(RequiredProperty.class.getName())) { setRequiredProperty(true); } }); } catch (final Exception e) { LOGGER.error(e.getMessage(), e); } }
StringBuilder sb = new StringBuilder(); sb.append("<b>").append(configurationMeta.getId()).append("</b>"); sb.append("<br/>").append(simpleHtmlEscape(configurationMeta.getType())); Deprecation deprecation = configurationMeta.getDeprecation(); if (deprecation != null) { sb.append("<br/><br/><b><i>"); final Object defaultValue = configurationMeta.getDefaultValue(); if (null != defaultValue) { sb.append("<br/><br/><i>Default:</i> "); final String description = configurationMeta.getDescription(); if (description != null) { sb.append("<br/><br/>").append(description); Hints hints = configurationMeta.getHints(); List<ValueHint> valueHints = hints.getValueHints(); if (valueHints != null && !valueHints.isEmpty()) {
.addValue("Type"); for (ConfigurationMetadataProperty option : options) { modelBuilder.addRow().addValue(option.getId()) .addValue(option.getDescription() == null ? "<unknown>" : option.getDescription()) .addValue(prettyPrintDefaultValue(option)) .addValue(option.getType() == null ? "<unknown>" : option.getType());
public String getText() { return configurationMeta.getId(); }
void addPropertiesProposals(String text, String startsWith, AppRegistration appRegistration, Set<String> alreadyPresentOptions, List<CompletionProposal> collector, int detailLevel){ Resource metadataResource = appRegistry.getAppMetadataResource(appRegistration); // For whitelisted properties, use their simple name if (metadataResource != null) { CompletionProposal.Factory proposals = CompletionProposal.expanding(text); for (ConfigurationMetadataProperty property : metadataResolver.listProperties(metadataResource)) { String name = property.getName(); if (!alreadyPresentOptions.contains(name) && name.startsWith(startsWith)) { collector.add(proposals .withSeparateTokens("--" + property.getName() + "=", property.getShortDescription())); } } // For other properties (including WL'ed in full form), use their id if (detailLevel > 1) { for (ConfigurationMetadataProperty property : metadataResolver.listProperties(metadataResource, true)) { String id = property.getId(); if (!alreadyPresentOptions.contains(id) && id.startsWith(startsWith)) { collector.add(proposals .withSeparateTokens("--" + property.getId() + "=", property.getShortDescription())); } } } } }
private void processNestedEnumProperties(final Set<ConfigurationMetadataProperty> properties, final Set<ConfigurationMetadataProperty> groups) { val propertiesToProcess = properties.stream() .filter(e -> { val matcher = NESTED_CLASS_PATTERN.matcher(e.getType()); return matcher.matches(); }) val matcher = NESTED_CLASS_PATTERN.matcher(e.getType()); matcher.matches(); if (member.isEnumDeclaration()) { val enumMem = member.asEnumDeclaration(); val builder = new StringBuilder(e.getDescription()); enumMem.getEntries() .stream() .append(entry.getJavadoc().get().getDescription().toText()) .append('.')); e.setDescription(builder.toString()); creator.createConfigurationProperty(field, e.getName());
StringBuilder sb = new StringBuilder(); Deprecation deprecation = cfgMeta.getDeprecation(); if (deprecation != null) { sb.append("<b>"); final String description = cfgMeta.getDescription(); if (description != null) { sb.append(description).append("<br/>"); sb.append("<tt>").append(simpleHtmlEscape(shortenJavaType(cfgMeta.getType()))).append("</tt>"); return sb.toString();
.filter(p -> p.getDeprecation() == null || !Deprecation.Level.ERROR.equals(p.getDeprecation().getLevel())) .collect(Collectors.toList()); val propName = StringUtils.substringAfterLast(entry.getName(), "."); val groupName = StringUtils.substringBeforeLast(entry.getName(), "."); val grp = groups .stream() .filter(g -> g.getName().equalsIgnoreCase(groupName)) .findFirst() .orElseThrow(() -> new IllegalArgumentException("Cant locate group " + groupName)); val matcher = PATTERN_GENERICS.matcher(grp.getType()); val className = matcher.find() ? matcher.group(1) : grp.getType(); val clazz = ClassUtils.getClass(className); hint.setName(entry.getName());
@Override public List<ValueHint> generateValueHints(ConfigurationMetadataProperty property, ClassLoader classLoader) { return property.getHints().getValueHints(); }
/** * Checks if property is error deprecated. * * @param property the configuration property * @return if property is error deprecated */ private boolean isDeprecatedError(ConfigurationMetadataProperty property) { return property.getDeprecation() != null && property.getDeprecation().getLevel() == Level.ERROR; }
/** * Is cas property ?. * * @param prop the prop * @return the boolean */ public static boolean isCasProperty(final ConfigurationMetadataProperty prop) { return prop.getName().startsWith(CasConfigurationProperties.PREFIX.concat(".")); } }
private String niceDefault(ConfigurationMetadataProperty property) { if (property.getDefaultValue() == null) { return "<none>"; } else if ("".equals(property.getDefaultValue())) { return "<empty string>"; } else { return stringify(property.getDefaultValue()); } }
.addValue("Type"); for (ConfigurationMetadataProperty option : options) { modelBuilder.addRow().addValue(option.getId()) .addValue(option.getDescription() == null ? "<unknown>" : option.getDescription()) .addValue(prettyPrintDefaultValue(option)) .addValue(option.getType() == null ? "<unknown>" : option.getType());
@Override public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) { super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); if (value instanceof ConfigurationMetadataProperty) { ConfigurationMetadataProperty prop = (ConfigurationMetadataProperty) value; if (prop.isDeprecated()) { setText(String.format("<html><s>%s", prop.getId())); if (Utils.isErrorDeprecated(prop)) { setForeground(UIManager.getColor("nb.errorForeground")); } } else { setText(prop.getId()); } } return this; }
@Override public boolean isExclusive(ConfigurationMetadataProperty property) { for (ValueProvider valueProvider : property.getHints().getValueProviders()) { if ("any".equals(valueProvider.getName())) { return false; } } return true; } }