1 package net.sf.prefixedproperties.spring.environmentfactories;
2
3 import java.util.Collections;
4 import java.util.List;
5
6 import org.apache.commons.lang.StringUtils;
7
8 import net.sf.prefixedproperties.spring.EnvironmentFactory;
9
10
11
12
13
14
15
16
17 public class FallbackEnvironmentFactory implements EnvironmentFactory {
18
19 private List<EnvironmentFactory> environmentFactories = Collections.emptyList();
20
21 @Override
22 public String getEnvironment() {
23 for (EnvironmentFactory environmentFactory : getEnvironmentFactories()) {
24 String environment = environmentFactory.getEnvironment();
25 if (StringUtils.isNotBlank(environment)){
26 return environment;
27 }
28 }
29 return null;
30 }
31
32 public List<EnvironmentFactory> getEnvironmentFactories() {
33 return environmentFactories;
34 }
35
36 public void setEnvironmentFactories(List<EnvironmentFactory> environmentFactories) {
37 this.environmentFactories = environmentFactories;
38 }
39
40 }