1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package org.basepom.mojo.propertyhelper;
16
17 import org.basepom.mojo.propertyhelper.macros.MacroType;
18
19 import java.io.File;
20 import java.security.SecureRandom;
21 import java.util.Collections;
22 import java.util.Map;
23 import java.util.Properties;
24 import java.util.Random;
25
26 import org.apache.maven.project.MavenProject;
27 import org.apache.maven.settings.Settings;
28
29
30
31
32 public interface FieldContext {
33
34
35 static FieldContext forTesting() {
36 return forTesting(new SecureRandom());
37 }
38
39
40 static FieldContext forTesting(Random random) {
41 return new FieldContext() {
42
43 @Override
44 public Map<String, MacroType> getMacros() {
45 return Collections.emptyMap();
46 }
47
48 @Override
49 public Properties getProjectProperties() {
50 return new Properties();
51 }
52
53 @Override
54 public MavenProject getProject() {
55 return new MavenProject();
56 }
57
58 @Override
59 public Settings getSettings() {
60 return new Settings();
61 }
62
63 @Override
64 public File getBasedir() {
65 throw new UnsupportedOperationException();
66 }
67
68 @Override
69 public InterpolatorFactory getInterpolatorFactory() {
70 return InterpolatorFactory.forTesting();
71 }
72
73 @Override
74 public TransformerRegistry getTransformerRegistry() {
75 return TransformerRegistry.INSTANCE;
76 }
77
78 @Override
79 public Random getRandom() {
80 return random;
81 }
82 };
83 }
84
85
86
87
88
89 Map<String, MacroType> getMacros();
90
91
92
93
94
95 Properties getProjectProperties();
96
97
98
99
100
101 MavenProject getProject();
102
103
104
105
106
107 Settings getSettings();
108
109
110
111
112
113
114 File getBasedir();
115
116
117
118
119
120 InterpolatorFactory getInterpolatorFactory();
121
122
123
124
125
126 TransformerRegistry getTransformerRegistry();
127
128
129
130
131 Random getRandom();
132 }