Skip to content

Commit f5c2e83

Browse files
committed
[Minor changes] Javadoc, typos, function names, etc.
Signed-off-by: Tatiana Leon <tatiana.leon@digi.com>
1 parent 7d4e31a commit f5c2e83

File tree

9 files changed

+36
-26
lines changed

9 files changed

+36
-26
lines changed

library/src/main/java/com/digi/xbee/api/exceptions/TransmitException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public String getTransmitStatusMessage() {
104104
@Override
105105
public String getMessage() {
106106
if (transmitStatus != null)
107-
return super.getMessage() + " > " + transmitStatus.getDescription();
107+
return super.getMessage() + " > " + transmitStatus.toString();
108108
return super.getMessage();
109109
}
110110
}

library/src/main/java/com/digi/xbee/api/models/HardwareVersion.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,7 @@ public String getDescription() {
7171
*
7272
* @param value Numeric value of the {@code HardwareVersion} retrieve.
7373
*
74-
* @return The {@code HardwareVersion} associated to the given value,
75-
* {@code null} if there is not any {@code HardwareVersion} with
76-
* that value.
74+
* @return The {@code HardwareVersion} associated to the given value.
7775
*/
7876
public static HardwareVersion get(int value) {
7977
HardwareVersionEnum hvEnum = HardwareVersionEnum.get(value);
@@ -90,8 +88,7 @@ public static HardwareVersion get(int value) {
9088
* @param description Description of the {@code HardwareVersion} retrieve.
9189
*
9290
* @return The {@code HardwareVersion} associated to the given value and
93-
* description, {@code null} if there is not any
94-
* {@code HardwareVersion} associated to those values.
91+
* description.
9592
*
9693
* @throws IllegalArgumentException if {@code value < 0} or
9794
* if {@code description.length() < 1}.

library/src/main/java/com/digi/xbee/api/models/HardwareVersionEnum.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,6 @@ public static HardwareVersionEnum get(int value) {
134134
*/
135135
@Override
136136
public String toString() {
137-
return HexUtils.byteToHexString((byte)value) + ": " + description;
137+
return String.format("0x%02X: %s", value, description);
138138
}
139139
}

library/src/main/java/com/digi/xbee/api/models/ModemStatusEvent.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313

1414
import java.util.HashMap;
1515

16-
import com.digi.xbee.api.utils.HexUtils;
17-
1816
/**
1917
* Enumerates the different modem status events. This enumeration list is
2018
* intended to be used within the
@@ -106,6 +104,6 @@ public static ModemStatusEvent get(int id) {
106104
*/
107105
@Override
108106
public String toString() {
109-
return HexUtils.byteToHexString((byte)id) + ": " + description;
107+
return String.format("0x%02X: %s", id, description);
110108
}
111109
}

library/src/main/java/com/digi/xbee/api/models/XBeeDiscoveryStatus.java

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ private XBeeDiscoveryStatus(int id, String description) {
5555
}
5656

5757
/**
58-
* Returns the discovery status ID.
58+
* Returns the numeric value of the discovery status identifier.
5959
*
60-
* @return The discovery status ID.
60+
* @return The discovery status identifier.
6161
*/
6262
public int getId() {
6363
return id;
@@ -73,17 +73,24 @@ public String getDescription() {
7373
}
7474

7575
/**
76-
* Returns the {@code XBeeDiscoveryStatus} associated to the given ID.
76+
* Returns the {@code XBeeDiscoveryStatus} associated to the given
77+
* identifier.
7778
*
78-
* @param id ID of the {@code XBeeDiscoveryStatus} to retrieve.
79+
* Returns {@code DISCOVERY_STATUS_UNKNOWN} if the identifier is not in the
80+
* enumeration.
7981
*
80-
* @return The {@code XBeeDiscoveryStatus} associated with the given ID.
82+
* @param id Identifier of the {@code XBeeDiscoveryStatus} to retrieve.
83+
*
84+
* @return The {@code XBeeDiscoveryStatus} associated with the given
85+
* identifier.
86+
* {@code DISCOVERY_STATUS_UNKNOWN} if the identifier is not in the
87+
* enumeration.
8188
*/
8289
public static XBeeDiscoveryStatus get(int id) {
8390
XBeeDiscoveryStatus status = lookupTable.get(id);
8491
if (status != null)
8592
return status;
86-
return XBeeDiscoveryStatus.DISCOVERY_STATUS_UNKNOWN;
93+
return DISCOVERY_STATUS_UNKNOWN;
8794
}
8895

8996
/*
@@ -92,6 +99,6 @@ public static XBeeDiscoveryStatus get(int id) {
9299
*/
93100
@Override
94101
public String toString() {
95-
return description;
102+
return String.format("%s (0x%02X)", description, id);
96103
}
97104
}

library/src/main/java/com/digi/xbee/api/packet/common/TransmitStatusPacket.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,15 @@ public boolean isBroadcast() {
239239
public LinkedHashMap<String, String> getAPIPacketParameters() {
240240
LinkedHashMap<String, String> parameters = new LinkedHashMap<String, String>();
241241
parameters.put("16-bit dest. address", HexUtils.prettyHexString(destAddress16.toString()));
242-
parameters.put("Tx. retry count", HexUtils.prettyHexString(HexUtils.integerToHexString(tranmistRetryCount, 1)) + " (" + tranmistRetryCount + ")");
243-
parameters.put("Delivery status", HexUtils.prettyHexString(HexUtils.integerToHexString(transmitStatus.getId(), 1)) + " (" + transmitStatus.getDescription() + ")");
244-
parameters.put("Discovery status", HexUtils.prettyHexString(HexUtils.integerToHexString(discoveryStatus.getId(), 1)) + " (" + discoveryStatus.getDescription() + ")");
242+
parameters.put("Tx. retry count",
243+
HexUtils.prettyHexString(HexUtils.integerToHexString(tranmistRetryCount, 1))
244+
+ " (" + tranmistRetryCount + ")");
245+
parameters.put("Delivery status",
246+
HexUtils.prettyHexString(HexUtils.integerToHexString(transmitStatus.getId(), 1))
247+
+ " (" + transmitStatus.getDescription() + ")");
248+
parameters.put("Discovery status",
249+
HexUtils.prettyHexString(HexUtils.integerToHexString(discoveryStatus.getId(), 1))
250+
+ " (" + discoveryStatus.getDescription() + ")");
245251
return parameters;
246252
}
247253
}

library/src/main/java/com/digi/xbee/api/packet/raw/TXStatusPacket.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,9 @@ public boolean isBroadcast() {
148148
@Override
149149
public LinkedHashMap<String, String> getAPIPacketParameters() {
150150
LinkedHashMap<String, String> parameters = new LinkedHashMap<String, String>();
151-
parameters.put("Status", HexUtils.prettyHexString(HexUtils.integerToHexString(transmitStatus.getId(), 1)) + " (" + transmitStatus.getDescription() + ")");
151+
parameters.put("Status",
152+
HexUtils.prettyHexString(HexUtils.integerToHexString(transmitStatus.getId(), 1))
153+
+ " (" + transmitStatus.getDescription() + ")");
152154
return parameters;
153155
}
154156
}

library/src/test/java/com/digi/xbee/api/models/HardwareVersionEnumTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public void testHardwareVersionEnumDescriptions() {
7272
* <p>Verify that each HardwareVersionEnum entry can be retrieved statically using its ID.</p>
7373
*/
7474
@Test
75-
public void testXBeeProtocolStaticAccess() {
75+
public void testHardwareVersionEnumStaticAccess() {
7676
for (HardwareVersionEnum hardwareVersionEnum:hardwareVersionValues)
7777
assertEquals(hardwareVersionEnum, HardwareVersionEnum.get(hardwareVersionEnum.getValue()));
7878
}

library/src/test/java/com/digi/xbee/api/models/HardwareVersionTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ public final void testEqualsWithNull() {
160160
* <p>Test the equals method with a non {@code HardwareVersion} value.</p>
161161
*/
162162
@Test
163-
public final void testEqualsWithNonXBeePacket() {
163+
public final void testEqualsWithNonHardwareVersion() {
164164
// Setup the resources for the test.
165165
HardwareVersion version = HardwareVersion.get(HardwareVersionEnum.XBP24B.getValue());
166166

@@ -177,7 +177,7 @@ public final void testEqualsWithNonXBeePacket() {
177177
* <p>Test the equals method with different {@code HardwareVersion}.</p>
178178
*/
179179
@Test
180-
public final void testEqualsWithDifferentXBeePacket() {
180+
public final void testEqualsWithDifferentHardwareVersion() {
181181
// Setup the resources for the test.
182182
HardwareVersion version1 = HardwareVersion.get(HardwareVersionEnum.XBP24B.getValue());
183183
HardwareVersion version2 = HardwareVersion.get(HardwareVersionEnum.X09_001.getValue());
@@ -271,7 +271,7 @@ public final void testEqualsIsConsistent() {
271271
* Test method for {@link com.digi.xbee.api.models.HardwareVersion#hashCode()}.
272272
*/
273273
@Test
274-
public final void testHashCodeWithEqualPackets() {
274+
public final void testHashCodeWithEqualHardwareVersions() {
275275
// Setup the resources for the test.
276276
HardwareVersion version1 = HardwareVersion.get(HardwareVersionEnum.XBP24B.getValue());
277277
HardwareVersion version2 = HardwareVersion.get(HardwareVersionEnum.XBP24B.getValue());
@@ -290,7 +290,7 @@ public final void testHashCodeWithEqualPackets() {
290290
* Test method for {@link com.digi.xbee.api.models.HardwareVersion#hashCode()}.
291291
*/
292292
@Test
293-
public final void testHashCodeWithDifferentPackets() {
293+
public final void testHashCodeWithDifferentHardwareVersions() {
294294
// Setup the resources for the test.
295295
HardwareVersion version1 = HardwareVersion.get(HardwareVersionEnum.XBP24B.getValue());
296296
HardwareVersion version2 = HardwareVersion.get(HardwareVersionEnum.X09_001.getValue());;

0 commit comments

Comments
 (0)