-
Notifications
You must be signed in to change notification settings - Fork 0
/
FieldMapper.java
36 lines (27 loc) · 1.2 KB
/
FieldMapper.java
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
34
35
36
import java.util.HashMap;
import java.util.Map;
public class FieldMapper {
private Map<String, String> fieldMap;
public FieldMapper() {
fieldMap = new HashMap<>();
}
public void addMapping(String sourceField, String destinationField) {
fieldMap.put(sourceField, destinationField);
}
public String getDestinationField(String sourceField) {
return fieldMap.get(sourceField);
}
public static void main(String[] args) {
FieldMapper mapper = new FieldMapper();
// 添加字段映射
mapper.addMapping("sourceField1", "destinationField1");
mapper.addMapping("sourceField2", "destinationField2");
// 获取目标字段
String destinationField1 = mapper.getDestinationField("sourceField1");
String destinationField2 = mapper.getDestinationField("sourceField2");
String destinationField3 = mapper.getDestinationField("sourceField3");
System.out.println("Destination field for sourceField1: " + destinationField1);
System.out.println("Destination field for sourceField2: " + destinationField2);
System.out.println("Destination field for sourceField3: " + destinationField3);
}
}