This commit is contained in:
@@ -189,12 +189,68 @@ public abstract class ConvertFactory<R extends Reader, W extends Writer> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final String getEntityAlias(Class clazz) {
|
final String getEntityAlias(Class clazz) {
|
||||||
|
if (clazz == String.class) return "A";
|
||||||
|
if (clazz == int.class) return "I";
|
||||||
|
if (clazz == Integer.class) return "i";
|
||||||
|
if (clazz == long.class) return "J";
|
||||||
|
if (clazz == Long.class) return "j";
|
||||||
|
if (clazz == byte.class) return "B";
|
||||||
|
if (clazz == Byte.class) return "b";
|
||||||
|
if (clazz == boolean.class) return "Z";
|
||||||
|
if (clazz == Boolean.class) return "z";
|
||||||
|
if (clazz == short.class) return "S";
|
||||||
|
if (clazz == Short.class) return "s";
|
||||||
|
if (clazz == char.class) return "C";
|
||||||
|
if (clazz == Character.class) return "c";
|
||||||
|
if (clazz == float.class) return "F";
|
||||||
|
if (clazz == Float.class) return "f";
|
||||||
|
if (clazz == double.class) return "D";
|
||||||
|
if (clazz == Double.class) return "d";
|
||||||
|
|
||||||
|
if (clazz == String[].class) return "[A";
|
||||||
|
if (clazz == int[].class) return "[I";
|
||||||
|
if (clazz == long[].class) return "[J";
|
||||||
|
if (clazz == byte[].class) return "[B";
|
||||||
|
if (clazz == boolean[].class) return "[Z";
|
||||||
|
if (clazz == short[].class) return "[S";
|
||||||
|
if (clazz == char[].class) return "[C";
|
||||||
|
if (clazz == float[].class) return "[F";
|
||||||
|
if (clazz == double[].class) return "[D";
|
||||||
|
|
||||||
ConvertEntity ce = (ConvertEntity) clazz.getAnnotation(ConvertEntity.class);
|
ConvertEntity ce = (ConvertEntity) clazz.getAnnotation(ConvertEntity.class);
|
||||||
if (ce != null && findEntityAlias(ce.value()) == null) entitys.put(ce.value(), clazz);
|
if (ce != null && findEntityAlias(ce.value()) == null) entitys.put(ce.value(), clazz);
|
||||||
return ce == null ? clazz.getName() : ce.value();
|
return ce == null ? clazz.getName() : ce.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
final Class getEntityAlias(String name) {
|
final Class getEntityAlias(String name) {
|
||||||
|
if ("A".equals(name)) return String.class;
|
||||||
|
if ("I".equals(name)) return int.class;
|
||||||
|
if ("i".equals(name)) return Integer.class;
|
||||||
|
if ("J".equals(name)) return long.class;
|
||||||
|
if ("j".equals(name)) return Long.class;
|
||||||
|
if ("B".equals(name)) return byte.class;
|
||||||
|
if ("b".equals(name)) return Byte.class;
|
||||||
|
if ("Z".equals(name)) return boolean.class;
|
||||||
|
if ("z".equals(name)) return Boolean.class;
|
||||||
|
if ("S".equals(name)) return short.class;
|
||||||
|
if ("s".equals(name)) return Short.class;
|
||||||
|
if ("C".equals(name)) return char.class;
|
||||||
|
if ("c".equals(name)) return Character.class;
|
||||||
|
if ("F".equals(name)) return float.class;
|
||||||
|
if ("f".equals(name)) return Float.class;
|
||||||
|
if ("D".equals(name)) return double.class;
|
||||||
|
if ("d".equals(name)) return Double.class;
|
||||||
|
|
||||||
|
if ("[A".equals(name)) return String[].class;
|
||||||
|
if ("[I".equals(name)) return int[].class;
|
||||||
|
if ("[J".equals(name)) return long[].class;
|
||||||
|
if ("[B".equals(name)) return byte[].class;
|
||||||
|
if ("[Z".equals(name)) return boolean[].class;
|
||||||
|
if ("[S".equals(name)) return short[].class;
|
||||||
|
if ("[C".equals(name)) return char[].class;
|
||||||
|
if ("[F".equals(name)) return float[].class;
|
||||||
|
if ("[D".equals(name)) return double[].class;
|
||||||
|
|
||||||
Class clazz = findEntityAlias(name);
|
Class clazz = findEntityAlias(name);
|
||||||
try {
|
try {
|
||||||
return clazz == null ? Class.forName(name) : clazz;
|
return clazz == null ? Class.forName(name) : clazz;
|
||||||
|
|||||||
@@ -436,8 +436,8 @@ public class CacheMemorySource<K extends Serializable, V extends Object> extends
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<CacheEntry<K, Object>> queryList() {
|
public List<K> queryKeys() {
|
||||||
return new ArrayList<>(container.values());
|
return new ArrayList<>(container.keySet());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -445,4 +445,14 @@ public class CacheMemorySource<K extends Serializable, V extends Object> extends
|
|||||||
return CompletableFuture.completedFuture(new ArrayList<>(container.values()));
|
return CompletableFuture.completedFuture(new ArrayList<>(container.values()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<CacheEntry<K, Object>> queryList() {
|
||||||
|
return new ArrayList<>(container.values());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CompletableFuture<List<K>> queryKeysAsync() {
|
||||||
|
return CompletableFuture.completedFuture(new ArrayList<>(container.keySet()));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,6 +57,8 @@ public interface CacheSource<K extends Serializable, V extends Object> {
|
|||||||
|
|
||||||
public void removeSetItem(final K key, final V value);
|
public void removeSetItem(final K key, final V value);
|
||||||
|
|
||||||
|
public List<K> queryKeys();
|
||||||
|
|
||||||
public List<CacheEntry<K, Object>> queryList();
|
public List<CacheEntry<K, Object>> queryList();
|
||||||
|
|
||||||
//---------------------- CompletableFuture 异步版 ---------------------------------
|
//---------------------- CompletableFuture 异步版 ---------------------------------
|
||||||
@@ -90,6 +92,8 @@ public interface CacheSource<K extends Serializable, V extends Object> {
|
|||||||
|
|
||||||
public CompletableFuture<Void> removeSetItemAsync(final K key, final V value);
|
public CompletableFuture<Void> removeSetItemAsync(final K key, final V value);
|
||||||
|
|
||||||
|
public CompletableFuture<List<K>> queryKeysAsync();
|
||||||
|
|
||||||
public CompletableFuture<List<CacheEntry<K, Object>>> queryListAsync();
|
public CompletableFuture<List<CacheEntry<K, Object>>> queryListAsync();
|
||||||
|
|
||||||
default CompletableFuture<Boolean> isOpenAsync() {
|
default CompletableFuture<Boolean> isOpenAsync() {
|
||||||
|
|||||||
Reference in New Issue
Block a user