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.Session;
26 import org.apache.maven.api.annotations.Nullable;
27
28
29
30
31
32
33
34 public final class Features {
35
36 private Features() {}
37
38
39
40
41 public static boolean consumerPom(@Nullable Properties userProperties) {
42 return doGet(userProperties, Constants.MAVEN_CONSUMER_POM, true);
43 }
44
45
46
47
48 public static boolean consumerPom(@Nullable Map<String, String> userProperties) {
49 return doGet(userProperties, Constants.MAVEN_CONSUMER_POM, true);
50 }
51
52
53
54
55 public static boolean consumerPom(@Nullable Session session) {
56 return consumerPom(session != null ? session.getUserProperties() : null);
57 }
58
59 private static boolean doGet(Properties userProperties, String key, boolean def) {
60 return doGet(userProperties != null ? userProperties.get(key) : null, def);
61 }
62
63 private static boolean doGet(Map<String, ?> userProperties, String key, boolean def) {
64 return doGet(userProperties != null ? userProperties.get(key) : null, def);
65 }
66
67 private static boolean doGet(Object val, boolean def) {
68 if (val instanceof Boolean) {
69 return (Boolean) val;
70 } else if (val != null) {
71 return Boolean.parseBoolean(val.toString());
72 } else {
73 return def;
74 }
75 }
76 }