package com.byoutline.cachedfield.internal;

import com.byoutline.cachedfield.ErrorListener;
import com.byoutline.cachedfield.ErrorListenerWithArg;
import com.byoutline.cachedfield.ProviderWithArg;
import com.byoutline.cachedfield.SuccessListener;
import com.byoutline.cachedfield.SuccessListenerWithArg;

import javax.annotation.Nonnull;
import javax.inject.Provider;

/**
 * Utility that converts clesses without args to classes with Void arg.
 *
 * @author Sebastian Kacprzak <sebastian.kacprzak at byoutline.com>
 */
public final class VoidArgumentFactory {

    private VoidArgumentFactory() {
    }

    public static <RETURN_TYPE> ProviderWithArg<RETURN_TYPE, Void> addVoidArg(
            @Nonnull final Provider<RETURN_TYPE> valueGetter) {
        return new ProviderWithArg<RETURN_TYPE, Void>() {

            @Override
            public RETURN_TYPE get(Void arg) {
                return valueGetter.get();
            }
        };
    }

    public static <RETURN_TYPE> SuccessListenerWithArg<RETURN_TYPE, Void> addVoidArg(
            @Nonnull final SuccessListener<RETURN_TYPE> successHandler) {
        return new SuccessListenerWithArg<RETURN_TYPE, Void>() {

            @Override
            public void valueLoaded(RETURN_TYPE value, Void arg) {
                successHandler.valueLoaded(value);
            }
        };
    }

    public static <RETURN_TYPE> ErrorListenerWithArg<Void> addVoidArg(
            @Nonnull final ErrorListener errorHandler) {
        return new ErrorListenerWithArg<Void>() {

            @Override
            public void valueLoadingFailed(Exception ex, Void arg) {
                errorHandler.valueLoadingFailed(ex);
            }
        };
    }
}

@@ -75,233 +75,9 @@
 eld.
-ErrorListener;%0Aimport com.byoutline.cachedfield.ErrorListenerWithArg;%0Aimport com.byoutline.cachedfield.ProviderWithArg;%0Aimport com.byoutline.cachedfield.SuccessListener;%0Aimport com.byoutline.cachedfield.SuccessListenerWithArg
+*
 ;%0A%0Ai
@@ -170,17 +170,17 @@
 verts cl
-e
+a
 sses wit

fix misspell.