1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.codehaus.plexus.metadata.gleaner;
18
19 import java.util.Collection;
20 import java.util.Map;
21
22 import org.codehaus.plexus.component.repository.ComponentDescriptor;
23 import org.codehaus.plexus.configuration.PlexusConfiguration;
24 import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration;
25
26
27
28
29
30 public abstract class ComponentGleanerSupport {
31 private static final String EMPTY_STRING = "";
32
33 protected String filterEmptyAsNull(final String value) {
34 if (value == null) {
35 return null;
36 } else if (EMPTY_STRING.equals(value.trim())) {
37 return null;
38 } else {
39 return value;
40 }
41 }
42
43 protected boolean isRequirementListType(final Class<?> type) {
44
45
46 return Collection.class.isAssignableFrom(type) || Map.class.isAssignableFrom(type);
47 }
48
49 protected void addChildConfiguration(final ComponentDescriptor<?> component, final PlexusConfiguration config) {
50
51
52
53 if (!component.hasConfiguration()) {
54 component.setConfiguration(new XmlPlexusConfiguration("configuration"));
55 }
56
57 component.getConfiguration().addChild(config);
58 }
59
60 protected String deHump(final String string) {
61
62
63 StringBuilder buff = new StringBuilder();
64
65 for (int i = 0; i < string.length(); i++) {
66 if (i != 0 && Character.isUpperCase(string.charAt(i))) {
67 buff.append('-');
68 }
69
70 buff.append(string.charAt(i));
71 }
72
73 return buff.toString().trim().toLowerCase();
74 }
75 }