This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package java.lang.annotation;
|
||||
|
||||
/**
|
||||
* The annotation type {@code java.lang.annotation.Repeatable} is
|
||||
* used to indicate that the annotation type whose declaration it
|
||||
* (meta-)annotates is <em>repeatable</em>. The value of
|
||||
* {@code @Repeatable} indicates the <em>containing annotation
|
||||
* type</em> for the repeatable annotation type.
|
||||
*
|
||||
* @since 1.8
|
||||
* @jls 9.6 Annotation Types
|
||||
* @jls 9.7 Annotations
|
||||
*/
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.ANNOTATION_TYPE)
|
||||
public @interface Repeatable {
|
||||
/**
|
||||
* Indicates the <em>containing annotation type</em> for the
|
||||
* repeatable annotation type.
|
||||
* @return the containing annotation type
|
||||
*/
|
||||
Class<? extends Annotation> value();
|
||||
}
|
||||
@@ -38,13 +38,13 @@ public abstract class Factory<R extends Reader, W extends Writer> {
|
||||
private final Encodeable<W, ?> anyEncoder = new AnyEncoder(this);
|
||||
|
||||
//-----------------------------------------------------------------------------------
|
||||
private final HashedMap<Class, Creator> creators = new HashedMap();
|
||||
private final ConcurrentHashMap<Class, Creator> creators = new ConcurrentHashMap();
|
||||
|
||||
private final Map<String, Class> entitys = new ConcurrentHashMap();
|
||||
|
||||
private final HashedMap<Type, Decodeable<R, ?>> decoders = new HashedMap();
|
||||
private final ConcurrentHashMap<Type, Decodeable<R, ?>> decoders = new ConcurrentHashMap();
|
||||
|
||||
private final HashedMap<Type, Encodeable<W, ?>> encoders = new HashedMap();
|
||||
private final ConcurrentHashMap<Type, Encodeable<W, ?>> encoders = new ConcurrentHashMap();
|
||||
|
||||
private final HashMap<AccessibleObject, ConvertColumnEntry> columnEntrys = new HashMap();
|
||||
|
||||
@@ -130,7 +130,11 @@ public abstract class Factory<R extends Reader, W extends Writer> {
|
||||
ConvertColumnEntry en = this.columnEntrys.get(field);
|
||||
if (en != null) return en;
|
||||
final ConvertType ct = this.getConvertType();
|
||||
for (ConvertColumn ref : field.getAnnotationsByType(ConvertColumn.class)) {
|
||||
final ConvertColumns ccs = field.getAnnotation(ConvertColumns.class);
|
||||
final ConvertColumn cc = field.getAnnotation(ConvertColumn.class);
|
||||
if (ccs == null && cc == null) return null;
|
||||
final ConvertColumn[] cca = (ccs == null) ? new ConvertColumn[]{cc} : ccs.value();
|
||||
for (ConvertColumn ref : cca) {
|
||||
if (ref.type().contains(ct)) {
|
||||
ConvertColumnEntry entry = new ConvertColumnEntry(ref);
|
||||
if (skipAllIgnore) {
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package org.redkale.convert;
|
||||
|
||||
import java.lang.reflect.*;
|
||||
|
||||
/**
|
||||
* 只增不减的伪Map类
|
||||
*
|
||||
* @see http://www.redkale.org
|
||||
* @author zhangjx
|
||||
* @param <K>
|
||||
* @param <V>
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public final class HashedMap<K extends Type, V> {
|
||||
|
||||
protected final transient Entry<K, V>[] table;
|
||||
|
||||
public HashedMap() {
|
||||
this(128);
|
||||
}
|
||||
|
||||
public HashedMap(int initCapacity) {
|
||||
this.table = new Entry[Math.max(initCapacity, 16)];
|
||||
}
|
||||
|
||||
public final V get(final K key) {
|
||||
final K k = key;
|
||||
final Entry<K, V>[] data = this.table;
|
||||
Entry<K, V> entry = data[k.hashCode() & (data.length - 1)];
|
||||
while (entry != null) {
|
||||
if (k == entry.key) return entry.value;
|
||||
entry = entry.next;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public final V put(K key, V value) {
|
||||
final K k = key;
|
||||
final Entry<K, V>[] data = this.table;
|
||||
final int index = k.hashCode() & (data.length - 1);
|
||||
Entry<K, V> entry = data[index];
|
||||
while (entry != null) {
|
||||
if (k == entry.key) {
|
||||
V old = entry.value;
|
||||
entry.value = value;
|
||||
return old;
|
||||
}
|
||||
entry = entry.next;
|
||||
}
|
||||
data[index] = new Entry(key, value, data[index]);
|
||||
return null;
|
||||
}
|
||||
|
||||
protected static final class Entry<K, V> {
|
||||
|
||||
protected V value;
|
||||
|
||||
protected final K key;
|
||||
|
||||
protected final Entry<K, V> next;
|
||||
|
||||
protected Entry(K key, V value, Entry<K, V> next) {
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
this.next = next;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user