All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.landawn.abacus.util.Clazz Maven / Gradle / Ivy

Go to download

A general programming library in Java/Android. It's easy to learn and simple to use with concise and powerful APIs.

There is a newer version: 5.3.16
Show newest version
/*
 * Copyright (C) 2018 HaiYang Li
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 */

package com.landawn.abacus.util;

import java.util.ArrayDeque;
import java.util.Collection;
import java.util.Deque;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.NavigableMap;
import java.util.NavigableSet;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Set;
import java.util.SortedMap;
import java.util.SortedSet;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.LinkedBlockingQueue;

/**
 * It's designed to provide a convenient way to parameterized the generic type (e.g. {@code List.class}).
 * 
* But the returned Class by all the methods doesn't have the actual parameterized type informations. For example: *
 * 
 * List<String> clazz = Clazz.ofList(String.class);
 * // clazz doesn't have the actual type parameters information.
 * // you won't be able to get type parameter {@code String} by: cls.getTypeParameters();
 * // To save the real type parameters: you need to either:
 * Type<List<String>> type = Type.of("List<String>"); // or Type.ofList(String.class)
 *
 * // Or
 * Type<List<String>> type = new TypeReference<List<String>>() {}.type();
 *
 * 
 * 
* * @author Haiyang Li * @since 1.2 */ public final class Clazz { @SuppressWarnings("rawtypes") public static final Class> PROPS_MAP = (Class) LinkedHashMap.class; @SuppressWarnings("rawtypes") public static final Class> MAP = (Class) Map.class; @SuppressWarnings("rawtypes") public static final Class> LINKED_HASH_MAP = (Class) LinkedHashMap.class; @SuppressWarnings("rawtypes") public static final Class> STRING_LIST = (Class) List.class; @SuppressWarnings("rawtypes") public static final Class> INTEGER_LIST = (Class) List.class; @SuppressWarnings("rawtypes") public static final Class> LONG_LIST = (Class) List.class; @SuppressWarnings("rawtypes") public static final Class> DOUBLE_LIST = (Class) List.class; @SuppressWarnings("rawtypes") public static final Class> OBJECT_LIST = (Class) List.class; @SuppressWarnings("rawtypes") public static final Class> STRING_SET = (Class) Set.class; @SuppressWarnings("rawtypes") public static final Class> INTEGER_SET = (Class) Set.class; @SuppressWarnings("rawtypes") public static final Class> LONG_SET = (Class) Set.class; @SuppressWarnings("rawtypes") public static final Class> DOUBLE_SET = (Class) Set.class; @SuppressWarnings("rawtypes") public static final Class> OBJECT_SET = (Class) Set.class; private Clazz() { // singleton. } /** * * @param * @param cls * @return */ @SuppressWarnings("rawtypes") public static Class of(Class cls) { return (Class) cls; } /** * * @param * @return */ @SuppressWarnings("rawtypes") public static Class> ofList() { return (Class) List.class; } /** * * @param * @param eleCls * @return */ @SuppressWarnings("rawtypes") public static Class> ofList(@SuppressWarnings("unused") final Class eleCls) { return (Class) List.class; } /** * Of linked list. * * @param * @return */ @SuppressWarnings("rawtypes") public static Class> ofLinkedList() { return (Class) LinkedList.class; } /** * Of linked list. * * @param * @param eleCls * @return */ @SuppressWarnings("rawtypes") public static Class> ofLinkedList(@SuppressWarnings("unused") final Class eleCls) { return (Class) LinkedList.class; } /** * Of list of map. * * @param the key type * @param the value type * @param keyCls * @param valueCls * @return */ @SuppressWarnings("rawtypes") public static Class>> ofListOfMap(@SuppressWarnings("unused") final Class keyCls, @SuppressWarnings("unused") final Class valueCls) { return (Class) List.class; } /** * Of set of map. * * @param the key type * @param the value type * @param keyCls * @param valueCls * @return */ @SuppressWarnings("rawtypes") public static Class>> ofSetOfMap(@SuppressWarnings("unused") final Class keyCls, @SuppressWarnings("unused") final Class valueCls) { return (Class) Set.class; } /** * * @param * @return */ @SuppressWarnings("rawtypes") public static Class> ofSet() { return (Class) Set.class; } /** * * @param * @param eleCls * @return */ @SuppressWarnings("rawtypes") public static Class> ofSet(@SuppressWarnings("unused") final Class eleCls) { return (Class) Set.class; } /** * Of linked hash set. * * @param * @return */ @SuppressWarnings("rawtypes") public static Class> ofLinkedHashSet() { return (Class) LinkedHashSet.class; } /** * Of linked hash set. * * @param * @param eleCls * @return */ @SuppressWarnings("rawtypes") public static Class> ofLinkedHashSet(@SuppressWarnings("unused") final Class eleCls) { return (Class) LinkedHashSet.class; } /** * Of sorted set. * * @param * @return */ @SuppressWarnings("rawtypes") public static Class> ofSortedSet() { return (Class) SortedSet.class; } /** * Of sorted set. * * @param * @param eleCls * @return */ @SuppressWarnings("rawtypes") public static Class> ofSortedSet(@SuppressWarnings("unused") final Class eleCls) { return (Class) SortedSet.class; } /** * Of navigable set. * * @param * @return */ @SuppressWarnings("rawtypes") public static Class> ofNavigableSet() { return (Class) NavigableSet.class; } /** * Of navigable set. * * @param * @param eleCls * @return */ @SuppressWarnings("rawtypes") public static Class> ofNavigableSet(@SuppressWarnings("unused") final Class eleCls) { return (Class) NavigableSet.class; } /** * Of tree set. * * @param * @return */ @SuppressWarnings("rawtypes") public static Class> ofTreeSet() { return (Class) TreeSet.class; } /** * Of tree set. * * @param * @param eleCls * @return */ @SuppressWarnings("rawtypes") public static Class> ofTreeSet(@SuppressWarnings("unused") final Class eleCls) { return (Class) TreeSet.class; } /** * * @param * @return */ @SuppressWarnings("rawtypes") public static Class> ofQueue() { return (Class) Queue.class; } /** * * @param * @param eleCls * @return */ @SuppressWarnings("rawtypes") public static Class> ofQueue(@SuppressWarnings("unused") final Class eleCls) { return (Class) Queue.class; } /** * * @param * @return */ @SuppressWarnings("rawtypes") public static Class> ofDeque() { return (Class) Deque.class; } /** * * @param * @param eleCls * @return */ @SuppressWarnings("rawtypes") public static Class> ofDeque(@SuppressWarnings("unused") final Class eleCls) { return (Class) Deque.class; } /** * Of array deque. * * @param * @return */ @SuppressWarnings("rawtypes") public static Class> ofArrayDeque() { return (Class) ArrayDeque.class; } /** * Of array deque. * * @param * @param eleCls * @return */ @SuppressWarnings("rawtypes") public static Class> ofArrayDeque(@SuppressWarnings("unused") final Class eleCls) { return (Class) ArrayDeque.class; } /** * Of concurrent linked queue. * * @param * @return */ @SuppressWarnings("rawtypes") public static Class> ofConcurrentLinkedQueue() { return (Class) ConcurrentLinkedQueue.class; } /** * Of concurrent linked queue. * * @param * @param eleCls * @return */ @SuppressWarnings("rawtypes") public static Class> ofConcurrentLinkedQueue(@SuppressWarnings("unused") final Class eleCls) { return (Class) ConcurrentLinkedQueue.class; } /** * Of priority queue. * * @param * @return */ @SuppressWarnings("rawtypes") public static Class> ofPriorityQueue() { return (Class) PriorityQueue.class; } /** * Of priority queue. * * @param * @param eleCls * @return */ @SuppressWarnings("rawtypes") public static Class> ofPriorityQueue(@SuppressWarnings("unused") final Class eleCls) { return (Class) PriorityQueue.class; } /** * Of linked blocking queue. * * @param * @return */ @SuppressWarnings("rawtypes") public static Class> ofLinkedBlockingQueue() { return (Class) LinkedBlockingQueue.class; } /** * Of linked blocking queue. * * @param * @param eleCls * @return */ @SuppressWarnings("rawtypes") public static Class> ofLinkedBlockingQueue(@SuppressWarnings("unused") final Class eleCls) { return (Class) LinkedBlockingQueue.class; } /** * * @param * @return */ @SuppressWarnings("rawtypes") public static Class> ofCollection() { return (Class) Collection.class; } /** * * @param * @param eleCls * @return */ @SuppressWarnings("rawtypes") public static Class> ofCollection(@SuppressWarnings("unused") final Class eleCls) { return (Class) Collection.class; } /** * * @param the key type * @param the value type * @return */ @SuppressWarnings("rawtypes") public static Class> ofMap() { return (Class) Map.class; } /** * * @param the key type * @param the value type * @param keyCls * @param valueCls * @return */ @SuppressWarnings("rawtypes") public static Class> ofMap(@SuppressWarnings("unused") final Class keyCls, @SuppressWarnings("unused") final Class valueCls) { return (Class) Map.class; } /** * Of linked hash map. * * @param the key type * @param the value type * @return */ @SuppressWarnings("rawtypes") public static Class> ofLinkedHashMap() { return (Class) LinkedHashMap.class; } /** * Of linked hash map. * * @param the key type * @param the value type * @param keyCls * @param valueCls * @return */ @SuppressWarnings("rawtypes") public static Class> ofLinkedHashMap(@SuppressWarnings("unused") final Class keyCls, @SuppressWarnings("unused") final Class valueCls) { return (Class) LinkedHashMap.class; } /** * Of sorted map. * * @param the key type * @param the value type * @return */ @SuppressWarnings("rawtypes") public static Class> ofSortedMap() { return (Class) SortedMap.class; } /** * Of sorted map. * * @param the key type * @param the value type * @param keyCls * @param valueCls * @return */ @SuppressWarnings("rawtypes") public static Class> ofSortedMap(@SuppressWarnings("unused") final Class keyCls, @SuppressWarnings("unused") final Class valueCls) { return (Class) SortedMap.class; } /** * Of navigable map. * * @param the key type * @param the value type * @return */ @SuppressWarnings("rawtypes") public static Class> ofNavigableMap() { return (Class) NavigableMap.class; } /** * Of navigable map. * * @param the key type * @param the value type * @param keyCls * @param valueCls * @return */ @SuppressWarnings("rawtypes") public static Class> ofNavigableMap(@SuppressWarnings("unused") final Class keyCls, @SuppressWarnings("unused") final Class valueCls) { return (Class) NavigableMap.class; } /** * Of tree map. * * @param the key type * @param the value type * @return */ @SuppressWarnings("rawtypes") public static Class> ofTreeMap() { return (Class) TreeMap.class; } /** * Of tree map. * * @param the key type * @param the value type * @param keyCls * @param valueCls * @return */ @SuppressWarnings("rawtypes") public static Class> ofTreeMap(@SuppressWarnings("unused") final Class keyCls, @SuppressWarnings("unused") final Class valueCls) { return (Class) TreeMap.class; } /** * Of concurrent map. * * @param the key type * @param the value type * @return */ @SuppressWarnings("rawtypes") public static Class> ofConcurrentMap() { return (Class) ConcurrentMap.class; } /** * Of concurrent map. * * @param the key type * @param the value type * @param keyCls * @param valueCls * @return */ @SuppressWarnings("rawtypes") public static Class> ofConcurrentMap(@SuppressWarnings("unused") final Class keyCls, @SuppressWarnings("unused") final Class valueCls) { return (Class) ConcurrentMap.class; } /** * Of concurrent hash map. * * @param the key type * @param the value type * @return */ @SuppressWarnings("rawtypes") public static Class> ofConcurrentHashMap() { return (Class) ConcurrentHashMap.class; } /** * Of concurrent hash map. * * @param the key type * @param the value type * @param keyCls * @param valueCls * @return */ @SuppressWarnings("rawtypes") public static Class> ofConcurrentHashMap(@SuppressWarnings("unused") final Class keyCls, @SuppressWarnings("unused") final Class valueCls) { return (Class) ConcurrentHashMap.class; } /** * Of bi map. * * @param the key type * @param the value type * @return */ @SuppressWarnings("rawtypes") public static Class> ofBiMap() { return (Class) BiMap.class; } /** * Of bi map. * * @param the key type * @param the value type * @param keyCls * @param valueCls * @return */ @SuppressWarnings("rawtypes") public static Class> ofBiMap(@SuppressWarnings("unused") final Class keyCls, @SuppressWarnings("unused") final Class valueCls) { return (Class) BiMap.class; } /** * * @param * @return */ @SuppressWarnings("rawtypes") public static Class> ofMultiset() { return (Class) Multiset.class; } /** * * @param * @param eleCls * @return */ @SuppressWarnings("rawtypes") public static Class> ofMultiset(@SuppressWarnings("unused") final Class eleCls) { return (Class) Multiset.class; } /** * Of long multiset. * * @param * @return */ @SuppressWarnings("rawtypes") public static Class> ofLongMultiset() { return (Class) LongMultiset.class; } /** * Of long multiset. * * @param * @param eleCls * @return */ @SuppressWarnings("rawtypes") public static Class> ofLongMultiset(@SuppressWarnings("unused") final Class eleCls) { return (Class) LongMultiset.class; } /** * Of list multimap. * * @param the key type * @param * @return */ @SuppressWarnings("rawtypes") public static Class> ofListMultimap() { return (Class) ListMultimap.class; } /** * Of list multimap. * * @param the key type * @param * @param keyCls * @param valueEleCls * @return */ @SuppressWarnings("rawtypes") public static Class> ofListMultimap(@SuppressWarnings("unused") final Class keyCls, @SuppressWarnings("unused") final Class valueEleCls) { return (Class) ListMultimap.class; } /** * Of set multimap. * * @param the key type * @param * @return */ @SuppressWarnings("rawtypes") public static Class> ofSetMultimap() { return (Class) SetMultimap.class; } /** * Of set multimap. * * @param the key type * @param * @param keyCls * @param valueEleCls * @return */ @SuppressWarnings("rawtypes") public static Class> ofSetMultimap(@SuppressWarnings("unused") final Class keyCls, @SuppressWarnings("unused") final Class valueEleCls) { return (Class) SetMultimap.class; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy