Source:
<code>protected void processListenedPropertiesAnnotation(RuleBuildContext context, PatternDescr patternDescr, Pattern pattern) { String watchedValues = null; try { Watch watch = patternDescr.getTypedAnnotation(Watch.class); watchedValues = watch == null ? null : watch.value(); } catch (Exception e) { registerDescrBuildError(context, patternDescr, e.getMessage()); } if (watchedValues == null) { return; } List<String> settableProperties = getSettableProperties(context, patternDescr, pattern); List<String> listenedProperties = new ArrayList<String>(); for (String propertyName : watchedValues.split(",")) { propertyName = propertyName.trim(); if (propertyName.equals("*") || propertyName.equals("!*")) { if (listenedProperties.contains("*") || listenedProperties.contains("!*")) { registerDescrBuildError(context, patternDescr, "Duplicate usage of wildcard * in @" + Watch.class.getSimpleName() + " annotation"); } else { listenedProperties.add(propertyName); } continue; } boolean isNegative = propertyName.startsWith("!"); propertyName = isNegative ? propertyName.substring(1).trim() : propertyName; if (settableProperties != null && !settableProperties.contains(propertyName)) { registerDescrBuildError(context, patternDescr, "Unknown property " + propertyName + " in @" + Watch.class.getSimpleName() + " annotation"); } else if (listenedProperties.contains(propertyName) || listenedProperties.contains("!" + propertyName)) { registerDescrBuildError(context, patternDescr, "Duplicate property " + propertyName + " in @" + Watch.class.getSimpleName() + " annotation"); } else { listenedProperties.add(isNegative ? "!" + propertyName : propertyName); } } <START> KieTraitsCompiler traits = ((KnowledgeBuilderImpl) context.getKnowledgeBuilder()).getTraits(); <END> if(traits != null && traits.isAEvaluatorPresent(pattern.getConstraints())) { listenedProperties.add(TraitableBean.TRAITSET_FIELD_NAME); } pattern.setListenedProperties(listenedProperties); }</code><technical_language>This transforming collection another, operate subset. types of a cost, is small. a lambda comprehend collection apply operation existing collection</technical_language>

Target:
protected void processListenedPropertiesAnnotation(RuleBuildContext context, PatternDescr patternDescr, Pattern pattern) { String watchedValues = null; try { Watch watch = patternDescr.getTypedAnnotation(Watch.class); watchedValues = watch == null ? null : watch.value(); } catch (Exception e) { registerDescrBuildError(context, patternDescr, e.getMessage()); } if (watchedValues == null) { return; } List<String> settableProperties = getSettableProperties(context, patternDescr, pattern); List<String> listenedProperties = new ArrayList<String>(); for (String propertyName : watchedValues.split(",")) { propertyName = propertyName.trim(); if (propertyName.equals("*") || propertyName.equals("!*")) { if (listenedProperties.contains("*") || listenedProperties.contains("!*")) { registerDescrBuildError(context, patternDescr, "Duplicate usage of wildcard * in @" + Watch.class.getSimpleName() + " annotation"); } else { listenedProperties.add(propertyName); } continue; } boolean isNegative = propertyName.startsWith("!"); propertyName = isNegative ? propertyName.substring(1).trim() : propertyName; if (settableProperties != null && !settableProperties.contains(propertyName)) { registerDescrBuildError(context, patternDescr, "Unknown property " + propertyName + " in @" + Watch.class.getSimpleName() + " annotation"); } else if (listenedProperties.contains(propertyName) || listenedProperties.contains("!" + propertyName)) { registerDescrBuildError(context, patternDescr, "Duplicate property " + propertyName + " in @" + Watch.class.getSimpleName() + " annotation"); } else { listenedProperties.add(isNegative ? "!" + propertyName : propertyName); } } pattern.setListenedProperties(listenedProperties); }