Skip to content

Commit 981da32

Browse files
committed
Minor code style improvements
1 parent 799f376 commit 981da32

2 files changed

Lines changed: 26 additions & 12 deletions

File tree

api/src/main/java/com/apicatalog/tree/io/TreeComparison.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -295,14 +295,14 @@ private static final Object nodeEquals(
295295
return false;
296296
}
297297

298-
if (leftAdapter.isEqualTo(rightAdapter)
299-
&& leftAdapter
300-
.features()
301-
.capabilities()
302-
.contains(Capability.DEEP_OBJECT_EQUALS)) {
303-
304-
return left.equals(right);
305-
}
298+
// if (leftAdapter.isEqualTo(rightAdapter)
299+
// && leftAdapter
300+
// .features()
301+
// .capabilities()
302+
// .contains(Capability.DEEP_OBJECT_EQUALS)) {
303+
//
304+
// return left.equals(right);
305+
// }
306306

307307
switch (leftType) {
308308
case FALSE:

cbor-adapter/src/main/java/com/apicatalog/tree/io/cbor/CborAdapter.java

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public Features features() {
9191
*/
9292
@Override
9393
public boolean isNode(Object node) {
94-
return node != null && (node instanceof DataItem || node instanceof List);
94+
return node instanceof DataItem || node instanceof List;
9595
}
9696

9797
/**
@@ -194,7 +194,7 @@ public Object property(Object key, TreeAdapter keyAdapter, Object node) {
194194
@Override
195195
public Entry<?, ?> next() {
196196
final DataItem key = kit.next();
197-
return new SimpleEntry<>(key, property(key, node));
197+
return java.util.Map.entry(key, property(key, node));
198198
}
199199

200200
@Override
@@ -246,6 +246,20 @@ public String stringValue(Object node) {
246246
return ((UnicodeString) node).getString();
247247
}
248248

249+
@Override
250+
public Number numericValue(Object node) {
251+
if (node instanceof HalfPrecisionFloat decimal) {
252+
return decimal.getValue();
253+
}
254+
if (node instanceof SinglePrecisionFloat decimal) {
255+
return decimal.getValue();
256+
}
257+
if (node instanceof DoublePrecisionFloat decimal) {
258+
return decimal.getValue();
259+
}
260+
return ((co.nstant.in.cbor.model.Number) node).getValue();
261+
}
262+
249263
/**
250264
* {@inheritDoc}
251265
*/
@@ -313,7 +327,7 @@ public Collection<DataItem> asIterable(Object node) {
313327
return array.getDataItems();
314328
}
315329
if (node instanceof List list) {
316-
return (List<DataItem>)list;
330+
return (List<DataItem>) list;
317331
}
318332
return List.of((DataItem) node);
319333
}
@@ -436,7 +450,7 @@ public int size(Object node) {
436450
}
437451
if (node instanceof List list) {
438452
return list.size();
439-
}
453+
}
440454
throw new ClassCastException("Node must be a Map or an Array, node=" + node);
441455
}
442456

0 commit comments

Comments
 (0)