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.internal.config;
21  
22  import org.apache.myfaces.tobago.context.Markup;
23  import org.apache.myfaces.tobago.internal.util.StringUtils;
24  
25  import java.io.Serializable;
26  
27  public class RendererConfig implements Serializable {
28  
29    private static final long serialVersionUID = 1L;
30  
31    private String name;
32    private Markup supportedMarkups = Markup.NULL;
33  
34    public String getName() {
35      return name;
36    }
37  
38    public void setName(final String name) {
39      this.name = StringUtils.uncapitalize(name);
40    }
41  
42    public boolean equals(final Object o) {
43      if (this == o) {
44        return true;
45      }
46      if (o == null || getClass() != o.getClass()) {
47        return false;
48      }
49  
50      final RendererConfig that = (RendererConfig) o;
51  
52      return name.equals(that.name);
53    }
54  
55    public boolean contains(final String markup) {
56      return supportedMarkups.contains(markup);
57    }
58  
59    public int hashCode() {
60      return name.hashCode();
61    }
62  
63    public void addSupportedMarkup(final String markup) {
64      supportedMarkups = supportedMarkups.add(Markup.valueOf(markup));
65    }
66  
67    public void merge(final RendererConfig rendererConfig) {
68       supportedMarkups = supportedMarkups.add(rendererConfig.supportedMarkups);
69    }
70  
71    public String toString() {
72      return "RendererConfig: " + getName() + " " + supportedMarkups;
73    }
74  }