Skip to content

Commit ce43f32

Browse files
committed
[ci] Remove unnecessary casts and add note where required
1 parent bff0e6c commit ce43f32

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

src/main/java/org/apache/ibatis/type/TypeHandlerRegistry.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,8 @@ public <T> void register(TypeReference<T> javaTypeReference, TypeHandler<? exten
382382

383383
// java type + jdbc type + handler
384384

385+
// Cast is required here
386+
@SuppressWarnings("cast")
385387
public <T> void register(Class<T> type, JdbcType jdbcType, TypeHandler<? extends T> handler) {
386388
register((Type) type, jdbcType, handler);
387389
}

src/test/java/org/apache/ibatis/domain/jpetstore/Cart.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public boolean containsItemId(String itemId) {
4343
}
4444

4545
public void addItem(Item item, boolean isInStock) {
46-
CartItem cartItem = (CartItem) itemMap.get(item.getItemId());
46+
CartItem cartItem = itemMap.get(item.getItemId());
4747
if (cartItem == null) {
4848
cartItem = new CartItem();
4949
cartItem.setItem(item);
@@ -56,7 +56,7 @@ public void addItem(Item item, boolean isInStock) {
5656
}
5757

5858
public Item removeItemById(String itemId) {
59-
CartItem cartItem = (CartItem) itemMap.remove(itemId);
59+
CartItem cartItem = itemMap.remove(itemId);
6060
if (cartItem == null) {
6161
return null;
6262
} else {
@@ -66,20 +66,20 @@ public Item removeItemById(String itemId) {
6666
}
6767

6868
public void incrementQuantityByItemId(String itemId) {
69-
CartItem cartItem = (CartItem) itemMap.get(itemId);
69+
CartItem cartItem = itemMap.get(itemId);
7070
cartItem.incrementQuantity();
7171
}
7272

7373
public void setQuantityByItemId(String itemId, int quantity) {
74-
CartItem cartItem = (CartItem) itemMap.get(itemId);
74+
CartItem cartItem = itemMap.get(itemId);
7575
cartItem.setQuantity(quantity);
7676
}
7777

7878
public BigDecimal getSubTotal() {
7979
BigDecimal subTotal = new BigDecimal("0");
8080
Iterator<CartItem> items = getCartItems();
8181
while (items.hasNext()) {
82-
CartItem cartItem = (CartItem) items.next();
82+
CartItem cartItem = items.next();
8383
Item item = cartItem.getItem();
8484
BigDecimal listPrice = item.getListPrice();
8585
BigDecimal quantity = new BigDecimal(String.valueOf(cartItem.getQuantity()));

src/test/java/org/apache/ibatis/domain/jpetstore/Order.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ public void initOrder(Account account, Cart cart) {
304304

305305
Iterator<CartItem> i = cart.getCartItems();
306306
while (i.hasNext()) {
307-
CartItem cartItem = (CartItem) i.next();
307+
CartItem cartItem = i.next();
308308
addLineItem(cartItem);
309309
}
310310

0 commit comments

Comments
 (0)