data: 自定义规则导入验证(3 场景 23 轮)+ 团队风格规则演示(5 规则全检出)
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
package com.team.style;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* 团队编码风格演示类。
|
||||
*/
|
||||
public class TeamStyleService {
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(TeamStyleService.class.getName());
|
||||
|
||||
private final List<OrderInfo> orderStore;
|
||||
|
||||
public TeamStyleService() {
|
||||
final List<OrderInfo> store = new ArrayList<>();
|
||||
store.add(new OrderInfo("order-001", new BigDecimal("99.90")));
|
||||
store.add(new OrderInfo("order-002", new BigDecimal("199.00")));
|
||||
this.orderStore = Collections.unmodifiableList(store);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询订单列表。
|
||||
*
|
||||
* @param orderId 订单编号
|
||||
* @return 订单列表
|
||||
*/
|
||||
public List<OrderInfo> handleOrderQuery(final String orderId) {
|
||||
if (orderId == null || orderId.isBlank()) {
|
||||
throw new IllegalArgumentException("orderId must not be blank");
|
||||
}
|
||||
final String normalizedOrderId = orderId.strip();
|
||||
final List<OrderInfo> result = new ArrayList<>();
|
||||
for (final OrderInfo order : orderStore) {
|
||||
if (order.getOrderId().equals(normalizedOrderId)) {
|
||||
result.add(order);
|
||||
}
|
||||
}
|
||||
if (LOGGER.isLoggable(Level.FINE)) {
|
||||
LOGGER.fine("order query executed");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单控制器。
|
||||
*/
|
||||
public static class OrderController {
|
||||
|
||||
private final TeamStyleService service;
|
||||
|
||||
public OrderController(final TeamStyleService service) {
|
||||
this.service = Objects.requireNonNull(service, "service must not be null");
|
||||
}
|
||||
|
||||
public List<OrderInfo> listOrders(final String orderId) {
|
||||
return service.handleOrderQuery(orderId);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单信息传输对象。
|
||||
*
|
||||
* @author demo
|
||||
*/
|
||||
public static class OrderInfo {
|
||||
|
||||
private final String orderId;
|
||||
private final BigDecimal amount;
|
||||
|
||||
public OrderInfo(final String orderId, final BigDecimal amount) {
|
||||
this.orderId = orderId;
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
public String getOrderId() {
|
||||
return orderId;
|
||||
}
|
||||
|
||||
public BigDecimal getAmount() {
|
||||
return amount;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user