/*
 * Copyright 2018 Rundeck, Inc. (http://rundeck.com)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.dtolabs.rundeck.core.plugins;

import java.io.Closeable;

/**
 * A Loaded plugin provider which can be closed when no longer needed
 * @author greg
 * @since 3/8/17
 */
public interface CloseableProvider<T> extends Closeable {
    T getProvider();
}

@@ -680,16 +680,52 @@
 oseable;
+%0Aimport java.util.function.Function;
 %0A%0A/**%0A *
@@ -792,16 +792,19 @@
  needed%0A
+ *%0A
  * @auth
@@ -869,16 +869,20 @@
 vider%3CT%3E
+%0A   
  extends
@@ -895,30 +895,854 @@
 able
- 
+%0A
 %7B%0A    
-T getProvider();
+/**%0A     * @return the provided instance%0A     */%0A    T getProvider();%0A%0A    /**%0A     * Convert a closeable provider of one type to a closeable of another type given a conversion function. The returned%0A     * closeable will manage closing this original closeable as well as the converted object if it is also closeable.%0A     *%0A     * @param converter converter function%0A     */%0A    default %3CX%3E CloseableProvider%3CX%3E convert(Function%3CT, X%3E converter) %7B%0A        X result = converter.apply(getProvider());%0A        //wrap the built source into another closeable provider%0A        return Closeables.closeableProvider(%0A            result,%0A            //close both the result if it is closeable, and this original closeable reference, when%0A            // released%0A            Closeables.single(Closeables.maybeCloseable(result), this)%0A        );%0A    %7D
 %0A%7D%0A

add utility method for converting to another type