From 52a327ea41cd08a5a1a2dd777e600705c438a5ea Mon Sep 17 00:00:00 2001
From: wentch <22250530@qq.com>
Date: Mon, 21 Dec 2015 10:17:28 +0800
Subject: [PATCH]
---
.../src/java/lang/annotation/Repeatable.java | 49 +++++++++++++
.../src/org/redkale/convert/Factory.java | 12 ++--
.../src/org/redkale/convert/HashedMap.java | 72 -------------------
3 files changed, 57 insertions(+), 76 deletions(-)
create mode 100644 android-jdk6-redkale/src/java/lang/annotation/Repeatable.java
delete mode 100644 android-jdk6-redkale/src/org/redkale/convert/HashedMap.java
diff --git a/android-jdk6-redkale/src/java/lang/annotation/Repeatable.java b/android-jdk6-redkale/src/java/lang/annotation/Repeatable.java
new file mode 100644
index 000000000..7a2daa822
--- /dev/null
+++ b/android-jdk6-redkale/src/java/lang/annotation/Repeatable.java
@@ -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 repeatable. The value of
+ * {@code @Repeatable} indicates the containing annotation
+ * type 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 containing annotation type for the
+ * repeatable annotation type.
+ * @return the containing annotation type
+ */
+ Class extends Annotation> value();
+}
diff --git a/android-jdk6-redkale/src/org/redkale/convert/Factory.java b/android-jdk6-redkale/src/org/redkale/convert/Factory.java
index b03e975d0..37a23d129 100644
--- a/android-jdk6-redkale/src/org/redkale/convert/Factory.java
+++ b/android-jdk6-redkale/src/org/redkale/convert/Factory.java
@@ -38,13 +38,13 @@ public abstract class Factory {
private final Encodeable anyEncoder = new AnyEncoder(this);
//-----------------------------------------------------------------------------------
- private final HashedMap creators = new HashedMap();
+ private final ConcurrentHashMap creators = new ConcurrentHashMap();
private final Map entitys = new ConcurrentHashMap();
- private final HashedMap> decoders = new HashedMap();
+ private final ConcurrentHashMap> decoders = new ConcurrentHashMap();
- private final HashedMap> encoders = new HashedMap();
+ private final ConcurrentHashMap> encoders = new ConcurrentHashMap();
private final HashMap columnEntrys = new HashMap();
@@ -130,7 +130,11 @@ public abstract class Factory {
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) {
diff --git a/android-jdk6-redkale/src/org/redkale/convert/HashedMap.java b/android-jdk6-redkale/src/org/redkale/convert/HashedMap.java
deleted file mode 100644
index a0f8db5a9..000000000
--- a/android-jdk6-redkale/src/org/redkale/convert/HashedMap.java
+++ /dev/null
@@ -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
- * @param
- */
-@SuppressWarnings("unchecked")
-public final class HashedMap {
-
- protected final transient Entry[] 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[] data = this.table;
- Entry 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[] data = this.table;
- final int index = k.hashCode() & (data.length - 1);
- Entry 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 {
-
- protected V value;
-
- protected final K key;
-
- protected final Entry next;
-
- protected Entry(K key, V value, Entry next) {
- this.key = key;
- this.value = value;
- this.next = next;
- }
- }
-}