Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
MetadataViewKeyImpl |
|
| 3.375;3.375 |
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 | 0 | { |
41 | 0 | this.viewId = viewId; |
42 | 0 | this.renderKitId = renderKitId; |
43 | 0 | this.locale = locale; |
44 | 0 | this.contracts = null; |
45 | 0 | } |
46 | ||
47 | public MetadataViewKeyImpl(String viewId, String renderKitId, Locale locale, String[] contracts) | |
48 | 0 | { |
49 | 0 | this.viewId = viewId; |
50 | 0 | this.renderKitId = renderKitId; |
51 | 0 | this.locale = locale; |
52 | 0 | this.contracts = contracts; |
53 | 0 | } |
54 | ||
55 | /** | |
56 | * @return the locale | |
57 | */ | |
58 | public Locale getLocale() | |
59 | { | |
60 | 0 | return locale; |
61 | } | |
62 | ||
63 | /** | |
64 | * @return the viewId | |
65 | */ | |
66 | @Override | |
67 | public String getViewId() | |
68 | { | |
69 | 0 | return viewId; |
70 | } | |
71 | ||
72 | /** | |
73 | * @return the contracts | |
74 | */ | |
75 | public String[] getContracts() | |
76 | { | |
77 | 0 | return Arrays.copyOf(contracts, contracts.length); |
78 | } | |
79 | ||
80 | /** | |
81 | * @return the renderKitId | |
82 | */ | |
83 | public String getRenderKitId() | |
84 | { | |
85 | 0 | return renderKitId; |
86 | } | |
87 | ||
88 | @Override | |
89 | public int hashCode() | |
90 | { | |
91 | 0 | int hash = 7; |
92 | 0 | hash = 17 * hash + (this.locale != null ? this.locale.hashCode() : 0); |
93 | 0 | hash = 17 * hash + (this.viewId != null ? this.viewId.hashCode() : 0); |
94 | 0 | hash = 17 * hash + Arrays.deepHashCode(this.contracts); |
95 | 0 | hash = 17 * hash + (this.renderKitId != null ? this.renderKitId.hashCode() : 0); |
96 | 0 | return hash; |
97 | } | |
98 | ||
99 | @Override | |
100 | public boolean equals(Object obj) | |
101 | { | |
102 | 0 | if (obj == null) |
103 | { | |
104 | 0 | return false; |
105 | } | |
106 | 0 | if (getClass() != obj.getClass()) |
107 | { | |
108 | 0 | return false; |
109 | } | |
110 | 0 | final MetadataViewKeyImpl other = (MetadataViewKeyImpl) obj; |
111 | 0 | if (this.locale != other.locale && (this.locale == null || !this.locale.equals(other.locale))) |
112 | { | |
113 | 0 | return false; |
114 | } | |
115 | 0 | if ((this.viewId == null) ? (other.viewId != null) : !this.viewId.equals(other.viewId)) |
116 | { | |
117 | 0 | return false; |
118 | } | |
119 | 0 | if (!Arrays.deepEquals(this.contracts, other.contracts)) |
120 | { | |
121 | 0 | return false; |
122 | } | |
123 | 0 | if ((this.renderKitId == null) ? (other.renderKitId != null) : !this.renderKitId.equals(other.renderKitId)) |
124 | { | |
125 | 0 | return false; |
126 | } | |
127 | 0 | return true; |
128 | } | |
129 | ||
130 | } |