1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.api.feature;
20
21 import java.util.Map;
22 import java.util.Properties;
23
24 import org.apache.maven.api.Constants;
25 import org.apache.maven.api.annotations.Nullable;
26
27
28
29
30
31
32
33 public final class Features {
34
35 private Features() {}
36
37
38
39
40 public static boolean mavenMaven3Personality(@Nullable Map<String, ?> userProperties) {
41 return doGet(userProperties, Constants.MAVEN_MAVEN3_PERSONALITY, false);
42 }
43
44
45
46
47 public static boolean consumerPom(@Nullable Map<String, ?> userProperties) {
48 return doGet(userProperties, Constants.MAVEN_CONSUMER_POM, !mavenMaven3Personality(userProperties));
49 }
50
51
52
53
54 public static boolean consumerPomFlatten(@Nullable Map<String, ?> userProperties) {
55 return doGet(userProperties, Constants.MAVEN_CONSUMER_POM_FLATTEN, false);
56 }
57
58 private static boolean doGet(Properties userProperties, String key, boolean def) {
59 return doGet(userProperties != null ? userProperties.get(key) : null, def);
60 }
61
62 private static boolean doGet(Map<String, ?> userProperties, String key, boolean def) {
63 return doGet(userProperties != null ? userProperties.get(key) : null, def);
64 }
65
66 private static boolean doGet(Object val, boolean def) {
67 if (val instanceof Boolean bool) {
68 return bool;
69 } else if (val != null) {
70 return Boolean.parseBoolean(val.toString());
71 } else {
72 return def;
73 }
74 }
75 }