Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove redundant array creation for calling varargs methods #3997

Merged
merged 1 commit into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
*/
package org.openhab.core.automation.internal.commands;

import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Locale;
Expand Down Expand Up @@ -142,7 +141,7 @@ public void execute(String[] args, Console console) {

@Override
public List<String> getUsages() {
return Arrays.asList(new String[] {
return List.of(
buildCommandUsage(LIST_MODULE_TYPES + " [-st] <filter> <language>",
"lists all Module Types. If filter is present, lists only matching Module Types."
+ " If language is missing, the default language will be used."),
Expand Down Expand Up @@ -174,7 +173,7 @@ public List<String> getUsages() {
"Enables the Rule, specified by given UID. If enable parameter is missing, "
+ "the result of the command will be visualization of enabled/disabled state of the rule, "
+ "if its value is \"true\" or \"false\", "
+ "the result of the command will be to set enable/disable on the Rule.") });
+ "the result of the command will be to set enable/disable on the Rule."));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ public static ModbusRegisterArray commandToRegisters(Command command, ModbusCons
// big endian byte ordering
byte hi = (byte) (shortValue >> 8);
byte lo = (byte) shortValue;
return new ModbusRegisterArray(new byte[] { hi, lo });
return new ModbusRegisterArray(hi, lo);
}
case INT32:
case UINT32: {
Expand All @@ -661,7 +661,7 @@ public static ModbusRegisterArray commandToRegisters(Command command, ModbusCons
byte lo1 = (byte) (intValue >> 16);
byte hi2 = (byte) (intValue >> 8);
byte lo2 = (byte) intValue;
return new ModbusRegisterArray(new byte[] { hi1, lo1, hi2, lo2 });
return new ModbusRegisterArray(hi1, lo1, hi2, lo2);
}
case INT32_SWAP:
case UINT32_SWAP: {
Expand All @@ -672,7 +672,7 @@ public static ModbusRegisterArray commandToRegisters(Command command, ModbusCons
byte hi2 = (byte) (intValue >> 8);
byte lo2 = (byte) intValue;
// Swapped order of registers
return new ModbusRegisterArray(new byte[] { hi2, lo2, hi1, lo1 });
return new ModbusRegisterArray(hi2, lo2, hi1, lo1);
}
case FLOAT32: {
float floatValue = numericCommand.floatValue();
Expand All @@ -682,7 +682,7 @@ public static ModbusRegisterArray commandToRegisters(Command command, ModbusCons
byte lo1 = (byte) (intBits >> 16);
byte hi2 = (byte) (intBits >> 8);
byte lo2 = (byte) intBits;
return new ModbusRegisterArray(new byte[] { hi1, lo1, hi2, lo2 });
return new ModbusRegisterArray(hi1, lo1, hi2, lo2);
}
case FLOAT32_SWAP: {
float floatValue = numericCommand.floatValue();
Expand All @@ -693,7 +693,7 @@ public static ModbusRegisterArray commandToRegisters(Command command, ModbusCons
byte hi2 = (byte) (intBits >> 8);
byte lo2 = (byte) intBits;
// Swapped order of registers
return new ModbusRegisterArray(new byte[] { hi2, lo2, hi1, lo1 });
return new ModbusRegisterArray(hi2, lo2, hi1, lo1);
}
case INT64:
case UINT64: {
Expand All @@ -707,7 +707,7 @@ public static ModbusRegisterArray commandToRegisters(Command command, ModbusCons
byte lo3 = (byte) (longValue >> 16);
byte hi4 = (byte) (longValue >> 8);
byte lo4 = (byte) longValue;
return new ModbusRegisterArray(new byte[] { hi1, lo1, hi2, lo2, hi3, lo3, hi4, lo4 });
return new ModbusRegisterArray(hi1, lo1, hi2, lo2, hi3, lo3, hi4, lo4);
}
case INT64_SWAP:
case UINT64_SWAP: {
Expand All @@ -722,7 +722,7 @@ public static ModbusRegisterArray commandToRegisters(Command command, ModbusCons
byte hi4 = (byte) (longValue >> 8);
byte lo4 = (byte) longValue;
// Swapped order of registers
return new ModbusRegisterArray(new byte[] { hi4, lo4, hi3, lo3, hi2, lo2, hi1, lo1 });
return new ModbusRegisterArray(hi4, lo4, hi3, lo3, hi2, lo2, hi1, lo1);
}
default:
throw new IllegalArgumentException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ private void updateProgress(int progress) {

void failedInternal(String errorMessageKey) {
this.state = InternalState.FINISHED;
String errorMessage = getMessage(ProgressCallbackImpl.class, errorMessageKey, new Object[] {});
String errorMessage = getMessage(ProgressCallbackImpl.class, errorMessageKey);
postResultInfoEvent(FirmwareUpdateResult.ERROR, errorMessage);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public static List<State> getAllStates() {
states.add(RewindFastforwardType.REWIND);
states.add(RewindFastforwardType.FASTFORWARD);

StringListType stringList = new StringListType(new String[] { "foo", "bar" });
StringListType stringList = new StringListType("foo", "bar");
states.add(stringList);

StringType string = new StringType("foo");
Expand Down