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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
use std::any::TypeId;
use lang_extension::any::*;
use lang_extension::convert::*;
use lang_extension::ops::function::*;
use crate::source::*;
pub mod default;
pub trait RawPropertyConfig: Key + Send + Sync {
fn get_raw_key(&self) -> Box<dyn Key>;
fn get_value_type(&self) -> TypeId;
fn get_raw_default_value(&self) -> Option<Box<dyn Value>>;
fn get_value_converters(&self) -> &[Box<dyn RawTypeConverter>];
fn get_value_filter(&self) -> Option<&dyn RawValueFilter>;
fn get_doc(&self) -> Option<&str>;
fn is_static(&self) -> bool;
fn is_required(&self) -> bool;
as_boxed!(RawPropertyConfig);
as_trait!(RawPropertyConfig);
}
boxed_key_trait!(RawPropertyConfig);
pub trait RawProperty: Value + Send + Sync {
fn get_raw_config(&self) -> &dyn RawPropertyConfig;
fn get_raw_value(&self) -> Option<Box<dyn Value>>;
fn get_source(&self) -> Option<Box<dyn ConfigurationSource>>;
fn add_raw_change_listener(&self, listener: RawPropertyChangeListener);
as_boxed!(RawProperty);
as_trait!(RawProperty);
}
boxed_value_trait!(RawProperty);
pub trait RawPropertyChangeEvent: Value + Send + Sync {
fn get_raw_property(&self) -> &dyn RawProperty;
fn get_raw_old_value(&self) -> Option<Box<dyn Value>>;
fn get_raw_new_value(&self) -> Option<Box<dyn Value>>;
fn get_change_time(&self) -> u128;
as_boxed!(RawPropertyChangeEvent);
as_trait!(RawPropertyChangeEvent);
}
boxed_value_trait!(RawPropertyChangeEvent);
pub type RawPropertyChangeListener = ConsumerRef<dyn RawPropertyChangeEvent>;
pub trait PropertyConfig<K: ?Sized + KeyConstraint, V: ?Sized + ValueConstraint> : RawPropertyConfig {
fn get_key(&self) -> Box<K>;
fn get_default_value(&self) -> Option<Box<V>>;
as_boxed!(PropertyConfig<K, V>);
}
boxed_key_trait!(PropertyConfig<K: ?Sized + KeyConstraint, V: ?Sized + ValueConstraint>);
pub trait PropertyConfigBuilder<K: ?Sized + KeyConstraint, V: ?Sized + ValueConstraint> {
fn set_key(&mut self, key: Box<K>) -> &mut dyn PropertyConfigBuilder<K, V>;
fn set_default_value(&mut self, default_value: Box<V>) -> &mut dyn PropertyConfigBuilder<K, V>;
fn add_value_converter(&mut self, value_converter: Box<dyn RawTypeConverter>)
-> &mut dyn PropertyConfigBuilder<K, V>;
fn add_value_converters(&mut self, value_converters: Vec<Box<dyn RawTypeConverter>>)
-> &mut dyn PropertyConfigBuilder<K, V>;
fn set_value_filter(&mut self, value_filter: Box<dyn ValueFilter<V>>)
-> &mut dyn PropertyConfigBuilder<K, V>;
fn set_doc(&mut self, doc: &str) -> &mut dyn PropertyConfigBuilder<K, V>;
fn set_static(&mut self, is_static: bool) -> &mut dyn PropertyConfigBuilder<K, V>;
fn set_required(&mut self, required: bool) -> &mut dyn PropertyConfigBuilder<K, V>;
fn build(&self) -> Box<dyn PropertyConfig<K, V>>;
}
pub trait Property<K: ?Sized + KeyConstraint, V: ?Sized + ValueConstraint> : RawProperty {
fn get_config(&self) -> &dyn PropertyConfig<K, V>;
fn get_value(&self) -> Option<Box<V>>;
fn add_change_listener(&self, listener: PropertyChangeListener<K, V>);
as_boxed!(Property<K, V>);
}
boxed_value_trait!(Property<K: ?Sized + KeyConstraint, V: ?Sized + ValueConstraint>);
pub trait PropertyChangeEvent<K: ?Sized + KeyConstraint, V: ?Sized + ValueConstraint> : RawPropertyChangeEvent {
fn get_property(&self) -> &dyn Property<K, V>;
fn get_old_value(&self) -> Option<Box<V>>;
fn get_new_value(&self) -> Option<Box<V>>;
as_boxed!(PropertyChangeEvent<K, V>);
}
boxed_value_trait!(PropertyChangeEvent<K: ?Sized + KeyConstraint, V: ?Sized + ValueConstraint>);
pub type PropertyChangeListener<K, V> = ConsumerRef<dyn PropertyChangeEvent<K, V>>;