yeg
2026-09-05 f522c9ffa487e3710d691e8b98df8c4f0cfafd43
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package com.battery.device.simulator;
 
import java.util.List;
 
/** 测试和独立协议合同使用的内存状态存储。 */
public final class InMemoryBtsSimulatorStateStore implements BtsSimulatorStateStore
{
    private SimulatorState state;
    private List<RecentRequest> recentRequests = List.of();
 
    public InMemoryBtsSimulatorStateStore() { }
    public InMemoryBtsSimulatorStateStore(SimulatorState state) { this.state = state; }
 
    @Override
    public synchronized SimulatorState loadOrInitialize(SimulatorState defaults)
    {
        if (state == null) state = defaults;
        return state;
    }
 
    @Override
    public synchronized void save(SimulatorState state) { this.state = state; }
    @Override
    public synchronized List<RecentRequest> loadRecentRequests() { return recentRequests; }
    @Override
    public synchronized void saveRecentRequests(List<RecentRequest> requests) { recentRequests = List.copyOf(requests); }
    @Override
    public synchronized void reset(SimulatorState defaults)
    {
        state = defaults;
        recentRequests = List.of();
    }
}