01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
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: */package org.apache.cxf.helpers;
19:
20: import java.util.Collection;
21: import java.util.Iterator;
22: import java.util.List;
23: import java.util.Map;
24: import java.util.Set;
25:
26: @SuppressWarnings("unchecked")
27: public final class CastUtils {
28:
29: private CastUtils() {
30: //utility class, never constructed
31: }
32:
33: public static <T, U> Map<T, U> cast(Map<?, ?> p) {
34: return (Map<T, U>) p;
35: }
36:
37: public static <T, U> Map<T, U> cast(Map<?, ?> p, Class<T> t,
38: Class<U> u) {
39: return (Map<T, U>) p;
40: }
41:
42: public static <T> Collection<T> cast(Collection<?> p) {
43: return (Collection<T>) p;
44: }
45:
46: public static <T> Collection<T> cast(Collection<?> p, Class<T> cls) {
47: return (Collection<T>) p;
48: }
49:
50: public static <T> List<T> cast(List<?> p) {
51: return (List<T>) p;
52: }
53:
54: public static <T> List<T> cast(List<?> p, Class<T> cls) {
55: return (List<T>) p;
56: }
57:
58: public static <T> Iterator<T> cast(Iterator<?> p) {
59: return (Iterator<T>) p;
60: }
61:
62: public static <T> Iterator<T> cast(Iterator<?> p, Class<T> cls) {
63: return (Iterator<T>) p;
64: }
65:
66: public static <T> Set<T> cast(Set<?> p) {
67: return (Set<T>) p;
68: }
69:
70: public static <T> Set<T> cast(Set<?> p, Class<T> cls) {
71: return (Set<T>) p;
72: }
73:
74: public static <T, U> Map.Entry<T, U> cast(Map.Entry<?, ?> p) {
75: return (Map.Entry<T, U>) p;
76: }
77:
78: public static <T, U> Map.Entry<T, U> cast(Map.Entry<?, ?> p,
79: Class<T> pc, Class<U> uc) {
80: return (Map.Entry<T, U>) p;
81: }
82:
83: }
|