This commit is contained in:
@@ -5,8 +5,8 @@
|
|||||||
*/
|
*/
|
||||||
package com.wentch.redkale.convert.bson;
|
package com.wentch.redkale.convert.bson;
|
||||||
|
|
||||||
import com.wentch.redkale.util.*;
|
|
||||||
import java.nio.*;
|
import java.nio.*;
|
||||||
|
import java.util.function.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import com.wentch.redkale.convert.*;
|
|||||||
import com.wentch.redkale.util.*;
|
import com.wentch.redkale.util.*;
|
||||||
import java.lang.reflect.*;
|
import java.lang.reflect.*;
|
||||||
import java.nio.*;
|
import java.nio.*;
|
||||||
|
import java.util.function.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BSON协议格式:
|
* BSON协议格式:
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import com.wentch.redkale.convert.*;
|
|||||||
import com.wentch.redkale.convert.ext.*;
|
import com.wentch.redkale.convert.ext.*;
|
||||||
import com.wentch.redkale.util.*;
|
import com.wentch.redkale.util.*;
|
||||||
import java.util.concurrent.atomic.*;
|
import java.util.concurrent.atomic.*;
|
||||||
|
import java.util.function.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ package com.wentch.redkale.convert.bson;
|
|||||||
import com.wentch.redkale.convert.*;
|
import com.wentch.redkale.convert.*;
|
||||||
import com.wentch.redkale.util.*;
|
import com.wentch.redkale.util.*;
|
||||||
import java.nio.*;
|
import java.nio.*;
|
||||||
|
import java.util.function.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -6,10 +6,10 @@
|
|||||||
package com.wentch.redkale.convert.json;
|
package com.wentch.redkale.convert.json;
|
||||||
|
|
||||||
import com.wentch.redkale.util.*;
|
import com.wentch.redkale.util.*;
|
||||||
import com.wentch.redkale.util.Supplier;
|
|
||||||
import java.nio.*;
|
import java.nio.*;
|
||||||
import java.nio.charset.*;
|
import java.nio.charset.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.function.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import com.wentch.redkale.util.*;
|
|||||||
import java.lang.reflect.*;
|
import java.lang.reflect.*;
|
||||||
import java.nio.*;
|
import java.nio.*;
|
||||||
import java.nio.charset.*;
|
import java.nio.charset.*;
|
||||||
|
import java.util.function.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ package com.wentch.redkale.convert.json;
|
|||||||
import com.wentch.redkale.convert.*;
|
import com.wentch.redkale.convert.*;
|
||||||
import com.wentch.redkale.util.*;
|
import com.wentch.redkale.util.*;
|
||||||
import java.util.concurrent.atomic.*;
|
import java.util.concurrent.atomic.*;
|
||||||
|
import java.util.function.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -22,7 +23,7 @@ public final class JsonReader implements Reader {
|
|||||||
private int limit;
|
private int limit;
|
||||||
|
|
||||||
public static ObjectPool<JsonReader> createPool(int max) {
|
public static ObjectPool<JsonReader> createPool(int max) {
|
||||||
return new ObjectPool<JsonReader>(max, new Creator<JsonReader>() {
|
return new ObjectPool<JsonReader>(max, new Creator<JsonReader>() { //为了兼容 JDK 6
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JsonReader create(Object... params) {
|
public JsonReader create(Object... params) {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ package com.wentch.redkale.convert.json;
|
|||||||
import com.wentch.redkale.convert.*;
|
import com.wentch.redkale.convert.*;
|
||||||
import com.wentch.redkale.util.*;
|
import com.wentch.redkale.util.*;
|
||||||
import java.nio.*;
|
import java.nio.*;
|
||||||
|
import java.util.function.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
package com.wentch.redkale.util;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* JDK 8 java.util.function.BiPredicate
|
|
||||||
*
|
|
||||||
* @author zhangjx
|
|
||||||
* @param <T>
|
|
||||||
* @param <U>
|
|
||||||
*/
|
|
||||||
public interface BiPredicate<T, U> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Evaluates this predicate on the given arguments.
|
|
||||||
*
|
|
||||||
* @param t the first input argument
|
|
||||||
* @param u the second input argument
|
|
||||||
* @return {@code true} if the input arguments match the predicate,
|
|
||||||
* otherwise {@code false}
|
|
||||||
*/
|
|
||||||
boolean test(T t, U u);
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
package com.wentch.redkale.util;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* JDK 8 java.util.function.Consumer
|
|
||||||
*
|
|
||||||
* @author zhangjx
|
|
||||||
* @param <T>
|
|
||||||
*/
|
|
||||||
public interface Consumer<T> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Performs this operation on the given argument.
|
|
||||||
*
|
|
||||||
* @param t the input argument
|
|
||||||
*/
|
|
||||||
void accept(T t);
|
|
||||||
}
|
|
||||||
@@ -8,6 +8,7 @@ import com.wentch.redkale.util.Creator.Creators;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.*;
|
import java.util.concurrent.*;
|
||||||
import java.util.concurrent.atomic.*;
|
import java.util.concurrent.atomic.*;
|
||||||
|
import java.util.function.*;
|
||||||
import java.util.logging.*;
|
import java.util.logging.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -63,6 +64,7 @@ public final class ObjectPool<T> implements Supplier<T> {
|
|||||||
this.creator = creator;
|
this.creator = creator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public T get() {
|
public T get() {
|
||||||
T result = queue.poll();
|
T result = queue.poll();
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
@@ -78,7 +80,10 @@ public final class ObjectPool<T> implements Supplier<T> {
|
|||||||
if (cycleCounter != null) cycleCounter.incrementAndGet();
|
if (cycleCounter != null) cycleCounter.incrementAndGet();
|
||||||
if (debug) {
|
if (debug) {
|
||||||
for (T t : queue) {
|
for (T t : queue) {
|
||||||
if (t == e) logger.log(Level.WARNING, "[" + Thread.currentThread().getName() + "] repeat offer the same object(" + e + ")", new Exception());
|
if (t == e) {
|
||||||
|
logger.log(Level.WARNING, "[" + Thread.currentThread().getName() + "] repeat offer the same object(" + e + ")", new Exception());
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
queue.offer(e);
|
queue.offer(e);
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
package com.wentch.redkale.util;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* JDK 8 java.util.function.Predicate
|
|
||||||
*
|
|
||||||
* @author zhangjx
|
|
||||||
* @param <T>
|
|
||||||
*/
|
|
||||||
public interface Predicate<T> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Evaluates this predicate on the given argument.
|
|
||||||
*
|
|
||||||
* @param t the input argument
|
|
||||||
* @return {@code true} if the input argument matches the predicate,
|
|
||||||
* otherwise {@code false}
|
|
||||||
*/
|
|
||||||
boolean test(T t);
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
package com.wentch.redkale.util;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* JDK 8 java.util.function.Supplier
|
|
||||||
*
|
|
||||||
* @author zhangjx
|
|
||||||
* @param <T>
|
|
||||||
*/
|
|
||||||
public interface Supplier<T> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets a result.
|
|
||||||
*
|
|
||||||
* @return a result
|
|
||||||
*/
|
|
||||||
T get();
|
|
||||||
}
|
|
||||||
54
android-jdk6-redkale/src/java/util/function/BiPredicate.java
Normal file
54
android-jdk6-redkale/src/java/util/function/BiPredicate.java
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2010, 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.util.function;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a predicate (boolean-valued function) of two arguments. This is
|
||||||
|
* the two-arity specialization of {@link Predicate}.
|
||||||
|
*
|
||||||
|
* <p>This is a <a href="package-summary.html">functional interface</a>
|
||||||
|
* whose functional method is {@link #test(Object, Object)}.
|
||||||
|
*
|
||||||
|
* @param <T> the type of the first argument to the predicate
|
||||||
|
* @param <U> the type of the second argument the predicate
|
||||||
|
*
|
||||||
|
* @see Predicate
|
||||||
|
* @since 1.8
|
||||||
|
*/
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface BiPredicate<T, U> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Evaluates this predicate on the given arguments.
|
||||||
|
*
|
||||||
|
* @param t the first input argument
|
||||||
|
* @param u the second input argument
|
||||||
|
* @return {@code true} if the input arguments match the predicate,
|
||||||
|
* otherwise {@code false}
|
||||||
|
*/
|
||||||
|
boolean test(T t, U u);
|
||||||
|
|
||||||
|
}
|
||||||
49
android-jdk6-redkale/src/java/util/function/Consumer.java
Normal file
49
android-jdk6-redkale/src/java/util/function/Consumer.java
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2010, 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.util.function;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents an operation that accepts a single input argument and returns no
|
||||||
|
* result. Unlike most other functional interfaces, {@code Consumer} is expected
|
||||||
|
* to operate via side-effects.
|
||||||
|
*
|
||||||
|
* <p>This is a <a href="package-summary.html">functional interface</a>
|
||||||
|
* whose functional method is {@link #accept(Object)}.
|
||||||
|
*
|
||||||
|
* @param <T> the type of the input to the operation
|
||||||
|
*
|
||||||
|
* @since 1.8
|
||||||
|
*/
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface Consumer<T> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Performs this operation on the given argument.
|
||||||
|
*
|
||||||
|
* @param t the input argument
|
||||||
|
*/
|
||||||
|
void accept(T t);
|
||||||
|
|
||||||
|
}
|
||||||
49
android-jdk6-redkale/src/java/util/function/Predicate.java
Normal file
49
android-jdk6-redkale/src/java/util/function/Predicate.java
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2010, 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.util.function;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a predicate (boolean-valued function) of one argument.
|
||||||
|
*
|
||||||
|
* <p>This is a <a href="package-summary.html">functional interface</a>
|
||||||
|
* whose functional method is {@link #test(Object)}.
|
||||||
|
*
|
||||||
|
* @param <T> the type of the input to the predicate
|
||||||
|
*
|
||||||
|
* @since 1.8
|
||||||
|
*/
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface Predicate<T> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Evaluates this predicate on the given argument.
|
||||||
|
*
|
||||||
|
* @param t the input argument
|
||||||
|
* @return {@code true} if the input argument matches the predicate,
|
||||||
|
* otherwise {@code false}
|
||||||
|
*/
|
||||||
|
boolean test(T t);
|
||||||
|
|
||||||
|
}
|
||||||
49
android-jdk6-redkale/src/java/util/function/Supplier.java
Normal file
49
android-jdk6-redkale/src/java/util/function/Supplier.java
Normal file
@@ -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.util.function;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a supplier of results.
|
||||||
|
*
|
||||||
|
* <p>There is no requirement that a new or distinct result be returned each
|
||||||
|
* time the supplier is invoked.
|
||||||
|
*
|
||||||
|
* <p>This is a <a href="package-summary.html">functional interface</a>
|
||||||
|
* whose functional method is {@link #get()}.
|
||||||
|
*
|
||||||
|
* @param <T> the type of results supplied by this supplier
|
||||||
|
*
|
||||||
|
* @since 1.8
|
||||||
|
*/
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface Supplier<T> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a result.
|
||||||
|
*
|
||||||
|
* @return a result
|
||||||
|
*/
|
||||||
|
T get();
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user