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  package org.apache.myfaces.view.facelets.pool.impl;
20  
21  import java.io.Serializable;
22  import java.util.Arrays;
23  import java.util.Locale;
24  
25  /**
26   *
27   * @author Leonardo Uribe
28   */
29  public class MetadataViewKeyImpl extends MetadataViewKey implements Serializable
30  {
31      private final Locale locale;
32      
33      private final String viewId;
34      
35      private final String[] contracts;
36      
37      private final String renderKitId;
38  
39      public MetadataViewKeyImpl(String viewId, String renderKitId, Locale locale)
40      {
41          this.viewId = viewId;
42          this.renderKitId = renderKitId;
43          this.locale = locale;
44          this.contracts = null;
45      }
46  
47      public MetadataViewKeyImpl(String viewId, String renderKitId, Locale locale, String[] contracts)
48      {
49          this.viewId = viewId;
50          this.renderKitId = renderKitId;
51          this.locale = locale;
52          this.contracts = contracts;
53      }
54  
55      /**
56       * @return the locale
57       */
58      public Locale getLocale()
59      {
60          return locale;
61      }
62  
63      /**
64       * @return the viewId
65       */
66      @Override
67      public String getViewId()
68      {
69          return viewId;
70      }
71  
72      /**
73       * @return the contracts
74       */
75      public String[] getContracts()
76      {
77          return Arrays.copyOf(contracts, contracts.length);
78      }
79  
80      /**
81       * @return the renderKitId
82       */
83      public String getRenderKitId()
84      {
85          return renderKitId;
86      }
87  
88      @Override
89      public int hashCode()
90      {
91          int hash = 7;
92          hash = 17 * hash + (this.locale != null ? this.locale.hashCode() : 0);
93          hash = 17 * hash + (this.viewId != null ? this.viewId.hashCode() : 0);
94          hash = 17 * hash + Arrays.deepHashCode(this.contracts);
95          hash = 17 * hash + (this.renderKitId != null ? this.renderKitId.hashCode() : 0);
96          return hash;
97      }
98  
99      @Override
100     public boolean equals(Object obj)
101     {
102         if (obj == null)
103         {
104             return false;
105         }
106         if (getClass() != obj.getClass())
107         {
108             return false;
109         }
110         final MetadataViewKeyImpl other = (MetadataViewKeyImpl) obj;
111         if (this.locale != other.locale && (this.locale == null || !this.locale.equals(other.locale)))
112         {
113             return false;
114         }
115         if ((this.viewId == null) ? (other.viewId != null) : !this.viewId.equals(other.viewId))
116         {
117             return false;
118         }
119         if (!Arrays.deepEquals(this.contracts, other.contracts))
120         {
121             return false;
122         }
123         if ((this.renderKitId == null) ? (other.renderKitId != null) : !this.renderKitId.equals(other.renderKitId))
124         {
125             return false;
126         }
127         return true;
128     }
129 
130 }