1 | |
package org.apache.onami.validation; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
import javax.inject.Inject; |
23 | |
import javax.inject.Provider; |
24 | |
import javax.inject.Singleton; |
25 | |
import javax.validation.ConstraintValidatorFactory; |
26 | |
import javax.validation.MessageInterpolator; |
27 | |
import javax.validation.TraversableResolver; |
28 | |
import javax.validation.spi.BootstrapState; |
29 | |
import javax.validation.spi.ConfigurationState; |
30 | |
import javax.validation.spi.ValidationProvider; |
31 | |
|
32 | |
import org.apache.bval.jsr303.ConfigurationImpl; |
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | 1 | @Singleton |
38 | |
final class ConfigurationStateProvider |
39 | |
implements Provider<ConfigurationState> |
40 | |
{ |
41 | |
|
42 | |
@com.google.inject.Inject( optional = true ) |
43 | |
private BootstrapState bootstrapState; |
44 | |
|
45 | |
private final ValidationProvider<?> validationProvider; |
46 | |
|
47 | |
private final TraversableResolver traversableResolver; |
48 | |
|
49 | |
private final MessageInterpolator messageInterpolator; |
50 | |
|
51 | |
private final ConstraintValidatorFactory constraintValidatorFactory; |
52 | |
|
53 | |
@Inject |
54 | |
public ConfigurationStateProvider( ValidationProvider<?> validationProvider, |
55 | |
TraversableResolver traversableResolver, |
56 | |
MessageInterpolator messageInterpolator, |
57 | |
ConstraintValidatorFactory constraintValidatorFactory ) |
58 | 1 | { |
59 | 1 | this.validationProvider = validationProvider; |
60 | 1 | this.traversableResolver = traversableResolver; |
61 | 1 | this.messageInterpolator = messageInterpolator; |
62 | 1 | this.constraintValidatorFactory = constraintValidatorFactory; |
63 | 1 | } |
64 | |
|
65 | |
|
66 | |
|
67 | |
|
68 | |
public ConfigurationState get() |
69 | |
{ |
70 | 1 | ConfigurationImpl configuration = new ConfigurationImpl( bootstrapState, validationProvider ); |
71 | 1 | configuration.traversableResolver( traversableResolver ); |
72 | 1 | configuration.messageInterpolator( messageInterpolator ); |
73 | 1 | configuration.constraintValidatorFactory( constraintValidatorFactory ); |
74 | 1 | return configuration; |
75 | |
} |
76 | |
|
77 | |
} |