File tree Expand file tree Collapse file tree 1 file changed +26
-2
lines changed
src/com/magento/idea/magento2plugin/util Expand file tree Collapse file tree 1 file changed +26
-2
lines changed Original file line number Diff line number Diff line change 2
2
* Copyright © Magento, Inc. All rights reserved.
3
3
* See COPYING.txt for license details.
4
4
*/
5
+
5
6
package com .magento .idea .magento2plugin .util ;
6
7
8
+ import java .util .regex .Matcher ;
9
+ import java .util .regex .Pattern ;
10
+
7
11
public class CamelCaseToHyphen {
8
12
private static CamelCaseToHyphen INSTANCE = null ;
13
+
14
+ /**
15
+ * getInstance.
16
+ * @return CamelCaseToHyphen
17
+ */
9
18
public static CamelCaseToHyphen getInstance () {
10
- if (null == INSTANCE ) INSTANCE = new CamelCaseToHyphen ();
19
+ if (null == INSTANCE ) {
20
+ INSTANCE = new CamelCaseToHyphen ();
21
+ }
11
22
return INSTANCE ;
12
23
}
13
24
25
+ /**
26
+ * convert.
27
+ * @param string the origin string.
28
+ * @return string
29
+ */
14
30
public String convert (String string ) {
15
- return string .toLowerCase ();
31
+ String regex = "(?=[A-Z][a-z])" ;
32
+ String subst = "-" ;
33
+ Pattern pattern = Pattern .compile (regex );
34
+ Matcher matcher = pattern .matcher (string );
35
+ String result = matcher .replaceAll (subst ).toLowerCase ();
36
+ if (result .charAt (0 ) == '-' ) {
37
+ return result .substring (1 );
38
+ }
39
+ return result ;
16
40
}
17
41
}
You can’t perform that action at this time.
0 commit comments