apupier commented on code in PR #21086:
URL: https://github.com/apache/camel/pull/21086#discussion_r2732411093
##########
core/camel-console/src/main/java/org/apache/camel/impl/console/BeanDevConsole.java:
##########
@@ -71,30 +71,14 @@ protected String doCallText(Map<String, Object> options) {
Stream<String> keys = beans.keySet().stream().filter(r ->
accept(r, filter)).sorted(String::compareToIgnoreCase);
keys.forEach(k -> {
Object bean = beans.get(k);
- if (bean != null) {
- boolean include = internal ||
!bean.getClass().getName().startsWith("org.apache.camel.");
- if (include) {
- sb.append(String.format(" %s (class: %s)%n", k,
bean.getClass().getName()));
-
- Map<String, Object> values = new TreeMap<>();
- if (properties) {
- try {
- bi.getProperties(bean, values, null);
- } catch (Throwable e) {
- // ignore
- }
- values.forEach((pk, pv) -> {
- if (pv == null) {
- if (nulls) {
- sb.append(String.format(" %s =
null%n", pk));
- }
- } else {
- String t = pv.getClass().getName();
- sb.append(String.format(" %s (%s) =
%s%n", pk, t, pv));
- }
- });
- }
- }
+ if (!shouldIncludeBean(bean, internal)) {
+ sb.append("\n");
+ return;
+ }
+
+ sb.append(String.format(" %s (class: %s)%n", k,
bean.getClass().getName()));
+ if (properties) {
+ appendBeanPropertiesText(sb, bi, bean, nulls);
}
Review Comment:
to keep happy path first, avoid negation and avoid ambiguous `return`,
factorize the sb.append('\n'), it can be written:
```
if (shouldIncludeBean(bean, internal)) {
sb.append(String.format(" %s (class: %s)%n", k,
bean.getClass().getName()));
if (properties) {
appendBeanPropertiesText(sb, bi, bean, nulls);
}
}
sb.append("\n");
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]