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

Use diamond operator and remove redundant type arguments #16249

Merged
merged 1 commit into from
Jan 9, 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.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ public static PWMRuleTemplate initialize() {
final List<Trigger> triggers = List.of(ModuleBuilder.createTrigger().withId(triggerId)
.withTypeUID(PWMTriggerType.UID).withLabel("PWM Trigger").build());

final Map<String, String> actionInputs = new HashMap<String, String>();
final Map<String, String> actionInputs = new HashMap<>();
actionInputs.put(PWMConstants.INPUT, triggerId + "." + PWMConstants.OUTPUT);

Set<String> tags = new HashSet<String>();
Set<String> tags = new HashSet<>();
tags.add("PWM");

return new PWMRuleTemplate(tags, triggers, Collections.emptyList(), Collections.emptyList(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
@Component
@NonNullByDefault
public class PWMTemplateProvider implements RuleTemplateProvider {
private final Map<String, RuleTemplate> providedRuleTemplates = new HashMap<String, RuleTemplate>();
private final Map<String, RuleTemplate> providedRuleTemplates = new HashMap<>();

public PWMTemplateProvider() {
providedRuleTemplates.put(PWMRuleTemplate.UID, PWMRuleTemplate.initialize());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public String toString() {

/** Utility routine to split an AD message into its component parts */
protected static List<String> splitMsg(String msg) {
List<String> l = new ArrayList<String>();
List<String> l = new ArrayList<>();
Matcher regexMatcher = SPLIT_REGEX.matcher(msg);
while (regexMatcher.find()) {
l.add(regexMatcher.group());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class PcapNetworkInterfaceWrapper {
/**
* Use this Guava function in order to create a {@link PcapNetworkInterfaceWrapper} instance.
*/
public static final Function<PcapNetworkInterface, PcapNetworkInterfaceWrapper> TRANSFORMER = new Function<PcapNetworkInterface, PcapNetworkInterfaceWrapper>() {
public static final Function<PcapNetworkInterface, PcapNetworkInterfaceWrapper> TRANSFORMER = new Function<>() {

@Override
public PcapNetworkInterfaceWrapper apply(PcapNetworkInterface pcapNetworkInterface) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public SmartHomeDevicesDiscovery(AccountHandler accountHandler) {
}

public void activate() {
activate(new Hashtable<String, Object>());
activate(new Hashtable<>());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ public void updateChannels(String interfaceName, List<JsonObject> stateList, Upd
float temperature = value.get("value").getAsFloat();
String scale = value.get("scale").getAsString();
if ("CELSIUS".equals(scale)) {
temperatureValue = new QuantityType<Temperature>(temperature, SIUnits.CELSIUS);
temperatureValue = new QuantityType<>(temperature, SIUnits.CELSIUS);
} else {
temperatureValue = new QuantityType<Temperature>(temperature, ImperialUnits.FAHRENHEIT);
temperatureValue = new QuantityType<>(temperature, ImperialUnits.FAHRENHEIT);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ public void updateChannels(String interfaceName, List<JsonObject> stateList, Upd
float temperature = value.get("value").getAsFloat();
String scale = value.get("scale").getAsString().toUpperCase();
if ("CELSIUS".equals(scale)) {
temperatureValue = new QuantityType<Temperature>(temperature, SIUnits.CELSIUS);
temperatureValue = new QuantityType<>(temperature, SIUnits.CELSIUS);
} else {
temperatureValue = new QuantityType<Temperature>(temperature, ImperialUnits.FAHRENHEIT);
temperatureValue = new QuantityType<>(temperature, ImperialUnits.FAHRENHEIT);
}
}
updateState(TARGET_SETPOINT.channelId, temperatureValue == null ? UnDefType.UNDEF : temperatureValue);
Expand All @@ -121,9 +121,9 @@ public void updateChannels(String interfaceName, List<JsonObject> stateList, Upd
float temperature = value.get("value").getAsFloat();
String scale = value.get("scale").getAsString().toUpperCase();
if ("CELSIUS".equals(scale)) {
temperatureValue = new QuantityType<Temperature>(temperature, SIUnits.CELSIUS);
temperatureValue = new QuantityType<>(temperature, SIUnits.CELSIUS);
} else {
temperatureValue = new QuantityType<Temperature>(temperature, ImperialUnits.FAHRENHEIT);
temperatureValue = new QuantityType<>(temperature, ImperialUnits.FAHRENHEIT);
}
}
updateState(UPPER_SETPOINT.channelId, temperatureValue == null ? UnDefType.UNDEF : temperatureValue);
Expand All @@ -135,9 +135,9 @@ public void updateChannels(String interfaceName, List<JsonObject> stateList, Upd
float temperature = value.get("value").getAsFloat();
String scale = value.get("scale").getAsString().toUpperCase();
if ("CELSIUS".equals(scale)) {
temperatureValue = new QuantityType<Temperature>(temperature, SIUnits.CELSIUS);
temperatureValue = new QuantityType<>(temperature, SIUnits.CELSIUS);
} else {
temperatureValue = new QuantityType<Temperature>(temperature, ImperialUnits.FAHRENHEIT);
temperatureValue = new QuantityType<>(temperature, ImperialUnits.FAHRENHEIT);
}
}
updateState(LOWER_SETPOINT.channelId, temperatureValue == null ? UnDefType.UNDEF : temperatureValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public void removeDevicesWithNoUpdate(List<SmartHomeDevice> devices) {
}
}
// check which groups needs an update
Set<Integer> groupsToUpdate = new HashSet<Integer>();
Set<Integer> groupsToUpdate = new HashSet<>();
for (UpdateGroup group : updateGroups.values()) {
long millisecondsSinceLastUpdate = updateTimeStamp.getTime() - group.lastUpdated.getTime();
if (syncAllGroups || millisecondsSinceLastUpdate >= group.intervalInSeconds * 1000) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class Group {
/**
* Set of zones belonging to a group
**/
private Set<Integer> zones = new LinkedHashSet<Integer>();
private Set<Integer> zones = new LinkedHashSet<>();

@Schema
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
public class ValidationError {

@Schema(required = true)
private List<String> loc = new ArrayList<String>();
private List<String> loc = new ArrayList<>();

@Schema(required = true)
private String msg;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public ScheduledExecutorService getScheduler() {

public void updateCDP(String channelName, Map<String, String> cdpMap) {
logger.trace("{} - Updating CDP for {}", this.thingID, channelName);
List<CommandOption> commandOptions = new ArrayList<CommandOption>();
List<CommandOption> commandOptions = new ArrayList<>();
cdpMap.forEach((key, value) -> commandOptions.add(new CommandOption(key, value)));
logger.trace("{} - CDP List: {}", this.thingID, commandOptions);
commandDescriptionProvider.setCommandOptions(new ChannelUID(getThing().getUID(), channelName), commandOptions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ private double getSunriseJulianDate(double jtransit, double jset) {
public static Map<SunPhaseName, Range> sortByValue(Map<SunPhaseName, Range> map) {
List<Entry<SunPhaseName, Range>> list = new ArrayList<>(map.entrySet());

Collections.sort(list, new Comparator<Entry<SunPhaseName, Range>>() {
Collections.sort(list, new Comparator<>() {
@Override
public int compare(Entry<SunPhaseName, Range> p1, Entry<SunPhaseName, Range> p2) {
Range p1Range = p1.getValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class AutomowerBindingConstants {
// introduce
// this in a future release
public static final String LAST_POSITION = GROUP_POSITIONS + "last-position";
public static final ArrayList<String> CHANNEL_POSITIONS = new ArrayList<String>(
public static final ArrayList<String> CHANNEL_POSITIONS = new ArrayList<>(
List.of(GROUP_POSITIONS + "position01", GROUP_POSITIONS + "position02", GROUP_POSITIONS + "position03",
GROUP_POSITIONS + "position04", GROUP_POSITIONS + "position05", GROUP_POSITIONS + "position06",
GROUP_POSITIONS + "position07", GROUP_POSITIONS + "position08", GROUP_POSITIONS + "position09",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class MowerData {
private Calendar calendar;
private Planner planner;
private Metadata metadata;
private ArrayList<Position> positions = new ArrayList<Position>();
private ArrayList<Position> positions = new ArrayList<>();

public System getSystem() {
return system;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;

import javax.measure.quantity.Dimensionless;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.automower.internal.AutomowerBindingConstants;
Expand Down Expand Up @@ -80,7 +78,7 @@ public class AutomowerHandler extends BaseThingHandler {
private final Logger logger = LoggerFactory.getLogger(AutomowerHandler.class);
private final TimeZoneProvider timeZoneProvider;

private AtomicReference<String> automowerId = new AtomicReference<String>(NO_ID);
private AtomicReference<String> automowerId = new AtomicReference<>(NO_ID);
private long lastQueryTimeMs = 0L;

private @Nullable ScheduledFuture<?> automowerPollingJob;
Expand Down Expand Up @@ -290,8 +288,8 @@ private void updateChannelState(@Nullable Mower mower) {

updateState(CHANNEL_STATUS_LAST_UPDATE,
new DateTimeType(toZonedDateTime(mower.getAttributes().getMetadata().getStatusTimestamp())));
updateState(CHANNEL_STATUS_BATTERY, new QuantityType<Dimensionless>(
mower.getAttributes().getBattery().getBatteryPercent(), Units.PERCENT));
updateState(CHANNEL_STATUS_BATTERY,
new QuantityType<>(mower.getAttributes().getBattery().getBatteryPercent(), Units.PERCENT));

updateState(CHANNEL_STATUS_ERROR_CODE, new DecimalType(mower.getAttributes().getMower().getErrorCode()));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class AwattarNonConsecutiveBestPriceResult extends AwattarBestPriceResult
public AwattarNonConsecutiveBestPriceResult(int size, ZoneId zoneId) {
super();
this.zoneId = zoneId;
members = new ArrayList<AwattarPrice>();
members = new ArrayList<>();
}

public void addMember(AwattarPrice member) {
Expand All @@ -59,7 +59,7 @@ public String toString() {

private void sort() {
if (!sorted) {
members.sort(new Comparator<AwattarPrice>() {
members.sort(new Comparator<>() {
@Override
public int compare(AwattarPrice o1, AwattarPrice o2) {
return Long.compare(o1.getStartTimestamp(), o2.getStartTimestamp());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public void refreshChannel(ChannelUID channelUID) {

AwattarBestPriceResult result;
if (config.consecutive) {
ArrayList<AwattarPrice> range = new ArrayList<AwattarPrice>(config.rangeDuration);
ArrayList<AwattarPrice> range = new ArrayList<>(config.rangeDuration);
range.addAll(getPriceRange(bridgeHandler, timerange,
(o1, o2) -> Long.compare(o1.getStartTimestamp(), o2.getStartTimestamp())));
AwattarConsecutiveBestPriceResult res = new AwattarConsecutiveBestPriceResult(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
import java.util.Map;
import java.util.UUID;

import javax.measure.quantity.Dimensionless;
import javax.measure.quantity.Temperature;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.core.library.types.QuantityType;
import org.openhab.core.library.unit.SIUnits;
Expand Down Expand Up @@ -55,15 +52,15 @@ protected void updateChannels(int[] is) {
logger.debug("Parsed data: {}", data);
Number humidity = data.get(AirthingsDataParser.HUMIDITY);
if (humidity != null) {
updateState(CHANNEL_ID_HUMIDITY, new QuantityType<Dimensionless>(humidity, Units.PERCENT));
updateState(CHANNEL_ID_HUMIDITY, new QuantityType<>(humidity, Units.PERCENT));
}
Number temperature = data.get(AirthingsDataParser.TEMPERATURE);
if (temperature != null) {
updateState(CHANNEL_ID_TEMPERATURE, new QuantityType<Temperature>(temperature, SIUnits.CELSIUS));
updateState(CHANNEL_ID_TEMPERATURE, new QuantityType<>(temperature, SIUnits.CELSIUS));
}
Number tvoc = data.get(AirthingsDataParser.TVOC);
if (tvoc != null) {
updateState(CHANNEL_ID_TVOC, new QuantityType<Dimensionless>(tvoc, Units.PARTS_PER_BILLION));
updateState(CHANNEL_ID_TVOC, new QuantityType<>(tvoc, Units.PARTS_PER_BILLION));
}
} catch (AirthingsParserException e) {
logger.error("Failed to parse data received from Airthings sensor: {}", e.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,7 @@
import java.util.Map;
import java.util.UUID;

import javax.measure.quantity.Dimensionless;
import javax.measure.quantity.Pressure;
import javax.measure.quantity.Temperature;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.core.library.dimension.RadiationSpecificActivity;
import org.openhab.core.library.types.QuantityType;
import org.openhab.core.library.unit.SIUnits;
import org.openhab.core.library.unit.Units;
Expand Down Expand Up @@ -57,33 +52,33 @@ protected void updateChannels(int[] is) {
logger.debug("Parsed data: {}", data);
Number humidity = data.get(AirthingsDataParser.HUMIDITY);
if (humidity != null) {
updateState(CHANNEL_ID_HUMIDITY, new QuantityType<Dimensionless>(humidity, Units.PERCENT));
updateState(CHANNEL_ID_HUMIDITY, new QuantityType<>(humidity, Units.PERCENT));
}
Number temperature = data.get(AirthingsDataParser.TEMPERATURE);
if (temperature != null) {
updateState(CHANNEL_ID_TEMPERATURE, new QuantityType<Temperature>(temperature, SIUnits.CELSIUS));
updateState(CHANNEL_ID_TEMPERATURE, new QuantityType<>(temperature, SIUnits.CELSIUS));
}
Number pressure = data.get(AirthingsDataParser.PRESSURE);
if (pressure != null) {
updateState(CHANNEL_ID_PRESSURE, new QuantityType<Pressure>(pressure, Units.MILLIBAR));
updateState(CHANNEL_ID_PRESSURE, new QuantityType<>(pressure, Units.MILLIBAR));
}
Number co2 = data.get(AirthingsDataParser.CO2);
if (co2 != null) {
updateState(CHANNEL_ID_CO2, new QuantityType<Dimensionless>(co2, Units.PARTS_PER_MILLION));
updateState(CHANNEL_ID_CO2, new QuantityType<>(co2, Units.PARTS_PER_MILLION));
}
Number tvoc = data.get(AirthingsDataParser.TVOC);
if (tvoc != null) {
updateState(CHANNEL_ID_TVOC, new QuantityType<Dimensionless>(tvoc, Units.PARTS_PER_BILLION));
updateState(CHANNEL_ID_TVOC, new QuantityType<>(tvoc, Units.PARTS_PER_BILLION));
}
Number radonShortTermAvg = data.get(AirthingsDataParser.RADON_SHORT_TERM_AVG);
if (radonShortTermAvg != null) {
updateState(CHANNEL_ID_RADON_ST_AVG, new QuantityType<RadiationSpecificActivity>(radonShortTermAvg,
Units.BECQUEREL_PER_CUBIC_METRE));
updateState(CHANNEL_ID_RADON_ST_AVG,
new QuantityType<>(radonShortTermAvg, Units.BECQUEREL_PER_CUBIC_METRE));
}
Number radonLongTermAvg = data.get(AirthingsDataParser.RADON_LONG_TERM_AVG);
if (radonLongTermAvg != null) {
updateState(CHANNEL_ID_RADON_LT_AVG,
new QuantityType<RadiationSpecificActivity>(radonLongTermAvg, Units.BECQUEREL_PER_CUBIC_METRE));
new QuantityType<>(radonLongTermAvg, Units.BECQUEREL_PER_CUBIC_METRE));
}
} catch (AirthingsParserException e) {
logger.error("Failed to parse data received from Airthings sensor: {}", e.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ public void handleResponse(Executor executor, ResponseListener listener, MadokaM
}
}

indoorTemperature = new QuantityType<Temperature>(iIndoorTemperature, SIUnits.CELSIUS);
indoorTemperature = new QuantityType<>(iIndoorTemperature, SIUnits.CELSIUS);

if (iOutdoorTemperature != null) {
outdoorTemperature = new QuantityType<Temperature>(iOutdoorTemperature, SIUnits.CELSIUS);
outdoorTemperature = new QuantityType<>(iOutdoorTemperature, SIUnits.CELSIUS);
}

logger.debug("Indoor Temp: {}", indoorTemperature);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ public void handleResponse(Executor executor, ResponseListener listener, MadokaM
Integer iIndoorFanHours = (int) (fanHours.getComputedValue(ByteOrder.LITTLE_ENDIAN));
Integer iIndoorPowerHours = (int) (powerHours.getComputedValue(ByteOrder.LITTLE_ENDIAN));

this.indoorOperationHours = new QuantityType<Time>(iIndoorOperationHours, Units.HOUR);
this.indoorFanHours = new QuantityType<Time>(iIndoorFanHours, Units.HOUR);
this.indoorPowerHours = new QuantityType<Time>(iIndoorPowerHours, Units.HOUR);
this.indoorOperationHours = new QuantityType<>(iIndoorOperationHours, Units.HOUR);
this.indoorFanHours = new QuantityType<>(iIndoorFanHours, Units.HOUR);
this.indoorPowerHours = new QuantityType<>(iIndoorPowerHours, Units.HOUR);

logger.debug("indoorOperationHours: {}", indoorOperationHours);
logger.debug("indoorFanHours: {}", indoorFanHours);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ public void handleResponse(Executor executor, ResponseListener listener, MadokaM
Integer iHeatingSetpoint = (int) (heatValue.getComputedValue() / 128.);
Integer iCoolingSetpoint = (int) (coolValue.getComputedValue() / 128.);

this.heatingSetpoint = new QuantityType<Temperature>(iHeatingSetpoint, SIUnits.CELSIUS);
this.coolingSetpoint = new QuantityType<Temperature>(iCoolingSetpoint, SIUnits.CELSIUS);
this.heatingSetpoint = new QuantityType<>(iHeatingSetpoint, SIUnits.CELSIUS);
this.coolingSetpoint = new QuantityType<>(iCoolingSetpoint, SIUnits.CELSIUS);

logger.debug("heatingSetpoint: {}", heatingSetpoint);
logger.debug("coolingSetpoint: {}", coolingSetpoint);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ public void setLabel(@Nullable String label) {

@Override
public List<@NonNull Channel> getChannels() {
return new ArrayList<Channel>();
return new ArrayList<>();
}

@Override
public List<@NonNull Channel> getChannelsOfGroup(String channelGroupId) {
return new ArrayList<Channel>();
return new ArrayList<>();
}

@Override
Expand Down Expand Up @@ -117,7 +117,7 @@ public ThingTypeUID getThingTypeUID() {

@Override
public Map<@NonNull String, @NonNull String> getProperties() {
return new HashMap<String, String>();
return new HashMap<>();
}

@Override
Expand Down
Loading