Skip to content

Commit

Permalink
Minor formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
bmalinowsky committed Sep 1, 2024
1 parent 4ac1078 commit a780241
Show file tree
Hide file tree
Showing 21 changed files with 44 additions and 52 deletions.
2 changes: 1 addition & 1 deletion src/io/calimero/DeviceDescriptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ public DD2(final int appManufacturer, final int deviceType, final int version,
d[i++] = (byte) (channelInfo3 >> 8);
d[i++] = (byte) (channelInfo3);
d[i++] = (byte) (channelInfo4 >> 8);
d[i++] = (byte) (channelInfo4);
d[i] = (byte) (channelInfo4);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/io/calimero/buffer/StateFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public void accept(final CEMI frame, final Configuration c)
if (!(f.getDestination() instanceof final GroupAddress dst))
return;
final DatapointModel<?> m = c.getDatapointModel();
Datapoint dp = null;
Datapoint dp;
if (m != null && ((dp = m.get(dst)) == null || !dp.isStateBased()))
return;
final byte[] d = f.getPayload();
Expand Down
4 changes: 2 additions & 2 deletions src/io/calimero/buffer/cache/ExpiringCache.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Calimero 2 - A library for KNX network access
Copyright (c) 2006, 2023 B. Malinowsky
Copyright (c) 2006, 2024 B. Malinowsky
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -120,7 +120,7 @@ public void removeExpired()
return;
final long now = System.currentTimeMillis();
final long duration = timeToExpire * 1000L;
CacheObject o = null;
CacheObject o;
synchronized (this) {
for (final Iterator<CacheObject> i = map.values().iterator(); i.hasNext();) {
o = i.next();
Expand Down
2 changes: 1 addition & 1 deletion src/io/calimero/datapoint/Datapoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public abstract class Datapoint
throw new KNXMLException("missing attribute " + ATTR_DPTID, r);
if (dptId.isEmpty())
dptId = null;
String a = null;
String a;
try {
a = r.getAttributeValue(null, ATTR_MAINNUMBER);
if (a != null)
Expand Down
6 changes: 1 addition & 5 deletions src/io/calimero/dptxlator/DptXlator8BitSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,7 @@ public final void setValue(final EnumSet<?> elements)
public final EnumSet<?> value() throws KNXFormatException {
final short v = fromDpt(0);
final EnumSet<?> set = EnumSet.allOf(((EnumDpt<?>) dpt).elements);
for (final var i = set.iterator(); i.hasNext();) {
final var e = i.next();
if ((v & (1 << e.ordinal())) == 0)
i.remove();
}
set.removeIf(e -> (v & (1 << e.ordinal())) == 0);
return set;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Calimero 2 - A library for KNX network access
Copyright (c) 2018, 2022 B. Malinowsky
Copyright (c) 2018, 2024 B. Malinowsky
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -167,7 +167,7 @@ protected static Map<String, DPT> getSubTypesStatic() {

private String fromDpt(final int index) {
final int offset = index * 3;
String s = "";
String s;

t.setAppendUnit(appendUnit);
final int valid = data[offset + 2];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Calimero 2 - A library for KNX network access
Copyright (c) 2018, 2022 B. Malinowsky
Copyright (c) 2018, 2024 B. Malinowsky
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -125,7 +125,7 @@ public Optional<Integer> colorTemp() {
final int valid = data[5];
if ((valid & 2) == 2) {
int offset = 2;
final int temperature = (data[offset++] << 8) | data[offset++];
final int temperature = (data[offset++] << 8) | data[offset];
return Optional.of(temperature);
}
return Optional.empty();
Expand All @@ -135,7 +135,7 @@ public Optional<Duration> fadingTime() {
final int valid = data[5];
if ((valid & 4) == 4) {
int offset = 0;
final long time = ((data[offset++] << 8) | data[offset++]) * 100;
final long time = ((data[offset++] << 8) | data[offset]) * 100;
return Optional.of(Duration.ofMillis(time));
}
return Optional.empty();
Expand Down Expand Up @@ -209,7 +209,7 @@ private String fromDpt(final int index) {
final double time = ((data[offset++] << 8) | data[offset++]) / 10d;
final int temperature = (data[offset++] << 8) | data[offset++];
final double brightness = data[offset++] * 100d / 255;
final int valid = data[offset++];
final int valid = data[offset];

final StringBuilder sb = new StringBuilder();
sb.append((valid & 1) == 1 ? formatter.format(brightness) : "-").append(appendUnit ? " % " : " ");
Expand Down
6 changes: 3 additions & 3 deletions src/io/calimero/dptxlator/DptXlatorXyY.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Calimero 2 - A library for KNX network access
Copyright (c) 2018, 2023 B. Malinowsky
Copyright (c) 2018, 2024 B. Malinowsky
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -185,7 +185,7 @@ private double[] fromDptDouble(final int index) {
final double y = ((data[offset++] << 8) | data[offset++]) / 65_535d;
final double brightness = data[offset++] * 100d / 255;

final int valid = data[offset++];
final int valid = data[offset];
final boolean clrValid = (valid & 2) == 2;
final boolean brightnessValid = (valid & 1) == 1;

Expand Down Expand Up @@ -242,7 +242,7 @@ protected void toDPT(final String value, final short[] dst, final int index) thr
dst[offset++] = (short) (yRaw >> 8);
dst[offset++] = ubyte(yRaw);
dst[offset++] = ubyte(brightnessRaw);
dst[offset++] = (short) valid;
dst[offset] = (short) valid;
}

private void toDpt(final double x, final double y, final double brightness) {
Expand Down
4 changes: 2 additions & 2 deletions src/io/calimero/dptxlator/DptXlatorXyYTransition.java
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ private double[] fromDptDouble(final int index) {
final double x = ((data[offset++] << 8) | data[offset++]) / 65_535d;
final double brightness = data[offset++] * 100d / 255;

final int valid = data[offset++];
final int valid = data[offset];
final boolean clrValid = (valid & 2) == 2;
final boolean brightnessValid = (valid & 1) == 1;

Expand Down Expand Up @@ -273,7 +273,7 @@ protected void toDPT(final String value, final short[] dst, final int index) thr
dst[offset++] = (short) (xRaw >> 8);
dst[offset++] = (short) (xRaw & 0xff);
dst[offset++] = brightnessRaw;
dst[offset++] = (short) valid;
dst[offset] = (short) valid;
}

private void toDpt(final double x, final double y, final double brightness, final Duration fadingTime) {
Expand Down
4 changes: 1 addition & 3 deletions src/io/calimero/knxnetip/ConnectionBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,6 @@ final void stopReceiver()

boolean waitForStateChange(final int initialState, final int timeout) throws InterruptedException
{
boolean changed = false;
long remaining = timeout * 1000L;
final long end = System.currentTimeMillis() + remaining;
lock.lock();
Expand All @@ -587,8 +586,7 @@ boolean waitForStateChange(final int initialState, final int timeout) throws Int
finally {
lock.unlock();
}
changed = remaining > 0;
return changed;
return remaining > 0;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/io/calimero/knxnetip/servicetype/ConnectRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public ConnectRequest(final CRI requestInfo, final int localPort)
{
super(KNXnetIPHeader.CONNECT_REQ);
cri = requestInfo;
ctrlPt = new HPAI((InetAddress) null, localPort);
ctrlPt = new HPAI(null, localPort);
dataPt = ctrlPt;
}

Expand Down
2 changes: 1 addition & 1 deletion src/io/calimero/knxnetip/servicetype/SearchRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public SearchRequest(final InetSocketAddress responseAddr, final Srp... searchPa
public SearchRequest(final int responsePort)
{
super(KNXnetIPHeader.SEARCH_REQ);
endpoint = new HPAI((InetAddress) null, responsePort);
endpoint = new HPAI(null, responsePort);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/io/calimero/knxnetip/servicetype/ServiceAck.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Calimero 2 - A library for KNX network access
Copyright (c) 2006, 2023 B. Malinowsky
Copyright (c) 2006, 2024 B. Malinowsky
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -79,7 +79,7 @@ public ServiceAck(final int serviceType, final byte[] data, final int offset)
throw new KNXFormatException("unsupported connection header");
channelid = data[i++] & 0xFF;
seq = data[i++] & 0xFF;
status = data[i++] & 0xFF;
status = data[i] & 0xFF;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/io/calimero/knxnetip/util/IPConfigDIB.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Calimero 2 - A library for KNX network access
Copyright (c) 2015, 2023 B. Malinowsky
Copyright (c) 2015, 2024 B. Malinowsky
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -192,7 +192,7 @@ public byte[] toByteArray()
buf[i++] = gw[k];

buf[i++] = (byte) caps;
buf[i++] = (byte) assignment;
buf[i] = (byte) assignment;
return buf;
}

Expand Down
4 changes: 2 additions & 2 deletions src/io/calimero/knxnetip/util/IPCurrentConfigDIB.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Calimero 2 - A library for KNX network access
Copyright (c) 2015, 2023 B. Malinowsky
Copyright (c) 2015, 2024 B. Malinowsky
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -194,7 +194,7 @@ public byte[] toByteArray()
buf[i++] = dhcp[k];

buf[i++] = (byte) assignment;
buf[i++] = 0;
buf[i] = 0;
return buf;
}

Expand Down
4 changes: 2 additions & 2 deletions src/io/calimero/knxnetip/util/TunnelingDib.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Calimero 2 - A library for KNX network access
Copyright (c) 2018, 2023 B. Malinowsky
Copyright (c) 2018, 2024 B. Malinowsky
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -98,7 +98,7 @@ public static SlotStatus of(final int value) {


public TunnelingDib(final Map<IndividualAddress, EnumSet<SlotStatus>> tunnelingSlots) {
this((short) 0xfe, tunnelingSlots);
this(0xfe, tunnelingSlots);
}

public TunnelingDib(final int maxApduLength, final Map<IndividualAddress, EnumSet<SlotStatus>> tunnelingSlots) {
Expand Down
4 changes: 2 additions & 2 deletions src/io/calimero/mgmt/LocalDeviceManagement.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Calimero 2 - A library for KNX network access
Copyright (c) 2015, 2022 B. Malinowsky
Copyright (c) 2015, 2024 B. Malinowsky
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -315,7 +315,7 @@ protected void initInterfaceObjects() throws KNXException, InterruptedException
final CEMIDevMgmt req = new CEMIDevMgmt(CEMIDevMgmt.MC_PROPREAD_REQ, DEVICE_OBJECT, 1,
PropertyAccess.PID.IO_LIST, 0, 1);
send(req, BlockingMode.Confirmation);
int objects = 0;
int objects;
try {
final byte[] ret = findFrame(CEMIDevMgmt.MC_PROPREAD_CON, req);
objects = (ret[0] & 0xff) << 8 | (ret[1] & 0xff);
Expand Down
2 changes: 1 addition & 1 deletion src/io/calimero/mgmt/ManagementProceduresImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@ public void assignDomainAndDeviceAddress(final byte[] domainAddress, final Indiv
while (Instant.now().isBefore(deadline) && list.isEmpty())
list = readSerialNumber();
if (list.size() != 1)
throw new KNXRemoteException("" + (list.isEmpty() ? "no" : list.size()) + " devices in programming mode");
throw new KNXRemoteException((list.isEmpty() ? "no" : list.size()) + " devices in programming mode");
final var sno = list.get(0);

final var link = ((TransportLayerImpl) tl).link();
Expand Down
14 changes: 7 additions & 7 deletions src/io/calimero/secure/Keyring.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Calimero 2 - A library for KNX network access
Copyright (c) 2019, 2023 B. Malinowsky
Copyright (c) 2019, 2024 B. Malinowsky
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -97,12 +97,12 @@ public enum Type {

// parse value from xsd Type enumeration
static Type from(final String type) {
switch (type) {
case "Backbone": return Backbone;
case "Tunneling": return Tunneling;
case "USB": return Usb; // important: USB is specified upper-case
}
throw new KNXIllegalArgumentException("unknown interface type " + type);
return switch (type) {
case "Backbone" -> Backbone;
case "Tunneling" -> Tunneling;
case "USB" -> Usb; // important: USB is specified upper-case
default -> throw new KNXIllegalArgumentException("unknown interface type " + type);
};
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/io/calimero/serial/FT12Connection.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Calimero 2 - A library for KNX network access
Copyright (c) 2006, 2023 B. Malinowsky
Copyright (c) 2006, 2024 B. Malinowsky
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -506,7 +506,7 @@ private void sendData(final byte[] data) throws IOException, KNXPortClosedExcept
for (final byte b : data)
buf[i++] = b;
buf[i++] = checksum(buf, 4, data.length + 1);
buf[i++] = END;
buf[i] = END;

state = ACK_PENDING;
os.write(buf);
Expand Down
10 changes: 4 additions & 6 deletions src/io/calimero/xml/XmlResolver.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Calimero 2 - A library for KNX network access
Copyright (c) 2006, 2022 B. Malinowsky
Copyright (c) 2006, 2024 B. Malinowsky
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -121,9 +121,8 @@ OutputStream resolveOutput(final String systemID)

Reader getInputReader(final InputStream is) throws KNXMLException
{
InputStream in = null;
try {
in = new BufferedInputStream(is);
InputStream in = new BufferedInputStream(is);
in.mark(9000);
// deduce encoding from first 4 bytes of stream
final byte[] start = new byte[4];
Expand Down Expand Up @@ -233,10 +232,9 @@ else if (state == 1 && s.startsWith("encoding")) {
}
else if (state == 1 || state == 2) {
if (s.startsWith("standalone")) {
standalone = getAttValue(s = s.substring(10));
standalone = getAttValue(s.substring(10));
if (!"yes".equals(standalone) && !"no".equals(standalone))
throw new KNXMLException("invalid standalone pseudo-attribute",
standalone, 0);
throw new KNXMLException("invalid standalone pseudo-attribute", standalone, 0);
break;
}
}
Expand Down

0 comments on commit a780241

Please sign in to comment.