Skip to content

Conversation

@spannm
Copy link
Contributor

@spannm spannm commented Jan 26, 2024

Non-functional change - make use of new Java language features available up to Java 17 LTS

  • Use String.repeat()
  • Replace statements with enhanced switch
  • Use pattern variable
  • Convert to enhanced for-loop
  • Prefer StringBuilder over StringBuffer
  • Remove unnecessary boxing/unboxing
  • Use Objects.equals() rather than equals() expression
  • Replace explicit types by diamond operator
  • Use lambdas for anonymous types
  • Use Comparator combinator
  • Introduce method references for lambdas
  • Change statement to expression lambdas
  • Check for null using method call

Copy link
Owner

@hypfvieh hypfvieh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please review the 2 marked files. Rest looks good


if (_variant.getType() instanceof DBusStructType && _variant.getValue() instanceof Object[]) {
Class<?>[] argTypes = Arrays.stream((Object[]) _variant.getValue()).map(Object::getClass).toArray(size -> new Class<?>[size]);
Class<?>[] argTypes = Arrays.stream((Object[]) _variant.getValue()).map(Object::getClass).toArray((IntFunction<Class<?>[]>) Class[]::new);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be simplified to Class<?>[] argTypes = Arrays.stream((Object[]) _variant.getValue()).map(Object::getClass).toArray(Class<?>[]::new);

Non-functional change - make use of new Java language features available up to Java 17 LTS

- Use String.repeat()
- Replace statements with enhanced switch
- Use pattern variable
- Convert to enhanced for-loop
- Prefer StringBuilder over StringBuffer
- Remove unnecessary boxing/unboxing
- Use Objects.equals() rather than equals() expression
- Replace explicit types by diamond operator
- Use lambdas for anonymous types
- Use Comparator combinator
- Introduce method references for lambdas
- Change statement to expression lambdas
- Check for null using method call
@spannm spannm force-pushed the dbus-java-lang-lvl-syntactic-sugaring branch from 954b11a to f5937d2 Compare January 30, 2024 07:36
@hypfvieh hypfvieh merged commit bebdc55 into hypfvieh:master Jan 30, 2024
@spannm spannm deleted the dbus-java-lang-lvl-syntactic-sugaring branch January 30, 2024 08:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants