You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.5 KiB

package common.ecommerce.shared.raw;
/**
* 列表响应里单条原始 JSON(不可变)。
*
* <p>用 {@code JsonNode.toString()} 切片,<b>保真</b>:平台返回了 DTO 未声明的
* 字段也会原样保留。{@link #key()} 是按下标对齐后回填的业务键(订单号),
* 对齐不成立时为 null,见 {@link RawPage#itemsAligned()}。</p>
*/
public final class RawItem {
/** 在响应数组中的下标,从 0 开始。 */
private final int index;
/** 对齐后的业务键(channelOrderId);无法确认时为 null。 */
private final String key;
/** 该条原始 JSON 文本。 */
private final String json;
private RawItem(int index, String key, String json) {
this.index = index;
this.key = key;
this.json = json;
}
/** 构造一条切片;{@code key} 允许为 null。 */
public static RawItem of(int index, String key, String json) {
return new RawItem(index, key, json);
}
/** 在响应数组中的下标,从 0 开始。 */
public int index() {
return index;
}
/** 对齐后的业务键;无法确认时为 null。 */
public String key() {
return key;
}
/** 该条原始 JSON 文本。 */
public String json() {
return json;
}
/** 只输出下标与业务键,不含正文。 */
@Override
public String toString() {
return "RawItem{index=" + index + ", key=" + key + '}';
}
}