View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  
20  package org.apache.myfaces.tobago.renderkit.css;
21  
22  /**
23   * @since Tobago 4.0.0
24   */
25  public enum Styles {
26  
27    width,
28    height,
29    minWidth,
30    minHeight,
31    maxWidth,
32    maxHeight,
33    left,
34    right,
35    top,
36    bottom,
37    paddingLeft,
38    paddingRight,
39    paddingTop,
40    paddingBottom,
41    marginLeft,
42    marginRight,
43    marginTop,
44    marginBottom,
45    overflowX,
46    overflowY,
47    display,
48    position,
49    textAlign,
50    backgroundImage,
51    backgroundPosition,
52    zIndex,
53    flexGrow,
54    flexShrink,
55    flexBasis,
56    gridTemplateColumns,
57    gridTemplateRows,
58    gridColumn,
59    gridRow;
60  
61    private String cssName;
62  
63    Styles() {
64      final char[] chars = name().toCharArray();
65      cssName = createCssName(chars);
66    }
67  
68    private String createCssName(final char[] chars) {
69      final StringBuilder builder = new StringBuilder(chars.length + 1);
70      for (final char c : chars) {
71        if (Character.isLowerCase(c)) {
72          builder.append(c);
73        } else {
74          builder.append('-');
75          builder.append(Character.toLowerCase(c));
76        }
77      }
78      return builder.toString();
79    }
80  
81    public String getCssName() {
82      return cssName;
83    }
84  }