1 /* 2 * #%L 3 * LambdaCallback.java - mongodb-async-driver - Allanbank Consulting, Inc. 4 * %% 5 * Copyright (C) 2011 - 2014 Allanbank Consulting, Inc. 6 * %% 7 * Licensed under the Apache License, Version 2.0 (the "License"); 8 * you may not use this file except in compliance with the License. 9 * You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, software 14 * distributed under the License is distributed on an "AS IS" BASIS, 15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 * See the License for the specific language governing permissions and 17 * limitations under the License. 18 * #L% 19 */ 20 package com.allanbank.mongodb; 21 22 /** 23 * LambdaCallback provides a lambda friendly interface for receiving the 24 * asynchronous results of a MongoDB operation. 25 * <p> 26 * The method name is based on the class (in 27 * {@code java.util.function.BiConsumer}) from Java 8. To support earlier JDKs 28 * the {@code andThen()} method is not supported. 29 * </p> 30 * <p> 31 * This interface follows the defacto convention that the first argument 32 * (left-side) to the method is the exception (error) and the second argument 33 * (right-side) is the value. Generally only one of the two arguments will be 34 * non-null. 35 * </p> 36 * 37 * @param <V> 38 * The type of the operation's result. 39 * 40 * @api.yes This interface is part of the driver's API. Public and protected 41 * members will be deprecated for at least 1 non-bugfix release 42 * (version numbers are <major>.<minor>.<bugfix>) 43 * before being removed or modified. 44 * @copyright 2013, Allanbank Consulting, Inc., All Rights Reserved 45 */ 46 public interface LambdaCallback<V> { 47 48 /** 49 * Called when the MongoDB operation has completed with the error or result 50 * of the operation. 51 * 52 * @param thrown 53 * The error encountered when processing the request. 54 * @param result 55 * The result of the operation. 56 */ 57 public void accept(Throwable thrown, V result); 58 }