1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.mybatis.generator.config;
17
18 import java.util.Map;
19 import java.util.Properties;
20
21 import org.jspecify.annotations.Nullable;
22
23 public abstract class PropertyHolder {
24 private final Properties properties;
25
26 protected PropertyHolder(AbstractBuilder<?> builder) {
27 properties = new Properties();
28 properties.putAll(builder.properties);
29 }
30
31 public @Nullable String getProperty(String name) {
32 return properties.getProperty(name);
33 }
34
35 public Properties getProperties() {
36 return properties;
37 }
38
39 public abstract static class AbstractBuilder<T extends AbstractBuilder<T>> {
40 private final Properties properties = new Properties();
41
42 @SuppressWarnings("UnusedReturnValue")
43 public T withProperty(Property property) {
44 properties.setProperty(property.name(), property.value());
45 return getThis();
46 }
47
48 public T withProperties(Map<Object, Object> properties) {
49 this.properties.putAll(properties);
50 return getThis();
51 }
52
53 protected abstract T getThis();
54 }
55 }