package com.funkyandroid.droidcon.uk.iosched.util;

import com.funkyandroid.droidcon.uk.iosched.R;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.text.Html;
import android.text.SpannableString;
import android.text.SpannableStringBuilder;
import android.text.method.LinkMovementMethod;
import android.text.style.ClickableSpan;
import android.view.LayoutInflater;
import android.view.View;
import android.webkit.WebView;
import android.widget.TextView;

/**
 * This is a set of helper methods for showing contextual help information in the app.
 */
public class HelpUtils {

    public static void showAbout(FragmentActivity activity) {
        FragmentManager fm = activity.getSupportFragmentManager();
        FragmentTransaction ft = fm.beginTransaction();
        Fragment prev = fm.findFragmentByTag("dialog_about");
        if (prev != null) {
            ft.remove(prev);
        }
        ft.addToBackStack(null);
        new AboutDialog().show(ft, "dialog_about");
    }

    public static class AboutDialog extends DialogFragment {

        private static final String VERSION_UNAVAILABLE = "N/A";

        public AboutDialog() {
        }

        @Override
        public Dialog onCreateDialog(Bundle savedInstanceState) {
            // Get app version
            PackageManager pm = getActivity().getPackageManager();
            String packageName = getActivity().getPackageName();
            String versionName;
            try {
                PackageInfo info = pm.getPackageInfo(packageName, 0);
                versionName = info.versionName;
            } catch (PackageManager.NameNotFoundException e) {
                versionName = VERSION_UNAVAILABLE;
            }
            // Build the about body view and append the link to see OSS licenses
            SpannableStringBuilder aboutBody = new SpannableStringBuilder();
            aboutBody.append(Html.fromHtml(getString(R.string.about_body, versionName)));
            SpannableString licensesLink = new SpannableString(getString(R.string.about_licenses));
            licensesLink.setSpan(new ClickableSpan() {

                @Override
                public void onClick(View view) {
                    HelpUtils.showOpenSourceLicenses(getActivity());
                }
            }, 0, licensesLink.length(), 0);
            aboutBody.append("\n\n");
            aboutBody.append(licensesLink);
            SpannableString eulaLink = new SpannableString(getString(R.string.about_eula));
            eulaLink.setSpan(new ClickableSpan() {

                @Override
                public void onClick(View view) {
                    HelpUtils.showEula(getActivity());
                }
            }, 0, eulaLink.length(), 0);
            aboutBody.append("\n\n");
            aboutBody.append(eulaLink);
            LayoutInflater layoutInflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            TextView aboutBodyView = (TextView) layoutInflater.inflate(R.layout.dialog_about, null);
            aboutBodyView.setText(aboutBody);
            aboutBodyView.setMovementMethod(new LinkMovementMethod());
            return new AlertDialog.Builder(getActivity()).setTitle(R.string.title_about).setView(aboutBodyView).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {

{
                    dialog.dismiss();
                }
            }).create();
        }
    }

    public static void showOpenSourceLicenses(FragmentActivity activity) {
        FragmentManager fm = activity.getSupportFragmentManager();
        FragmentTransaction ft = fm.beginTransaction();
        Fragment prev = fm.findFragmentByTag("dialog_licenses");
        if (prev != null) {
            ft.remove(prev);
        }
        ft.addToBackStack(null);
        new OpenSourceLicensesDialog().show(ft, "dialog_licenses");
    }

    public static class OpenSourceLicensesDialog extends DialogFragment {

        public OpenSourceLicensesDialog() {
        }

        @Override
        public Dialog onCreateDialog(Bundle savedInstanceState) {
            WebView webView = new WebView(getActivity());
            webView.loadUrl("file:///android_asset/licenses.html");
            return new AlertDialog.Builder(getActivity()).setTitle(R.string.about_licenses).setView(webView).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int whichButton) {
                    dialog.dismiss();
                }
            }).create();
        }
    }

    public static void showEula(FragmentActivity activity) {
        FragmentManager fm = activity.getSupportFragmentManager();
        FragmentTransaction ft = fm.beginTransaction();
        Fragment prev = fm.findFragmentByTag("dialog_eula");
        if (prev != null) {
            ft.remove(prev);
        }
        ft.addToBackStack(null);
        new EulaDialog().show(ft, "dialog_eula");
    }

    public static class EulaDialog extends DialogFragment {

        public EulaDialog() {
        }

        @Override
        public Dialog onCreateDialog(Bundle savedInstanceState) {
            int padding = getResources().getDimensionPixelSize(R.dimen.content_padding_normal);
            TextView eulaTextView = new TextView(getActivity());
            eulaTextView.setText(Html.fromHtml(getString(R.string.eula_text)));
            eulaTextView.setMovementMethod(LinkMovementMethod.getInstance());
            eulaTextView.setPadding(padding, padding, padding, padding);
            return new AlertDialog.Builder(getActivity()).setTitle(R.string.about_eula).setView(eulaTextView).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int whichButton) {
                    dialog.dismiss();
                }
            }).create();
        }
    }
}


{
                    HelpUtils.showOpenSourceLicenses(getActivity());
                }

package com.funkyandroid.droidcon.uk.iosched.util;

import com.funkyandroid.droidcon.uk.iosched.R;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.text.Html;
import android.text.SpannableString;
import android.text.SpannableStringBuilder;
import android.text.method.LinkMovementMethod;
import android.text.style.ClickableSpan;
import android.view.LayoutInflater;
import android.view.View;
import android.webkit.WebView;
import android.widget.TextView;

/**
 * This is a set of helper methods for showing contextual help information in the app.
 */
public class HelpUtils {

    public static void showAbout(FragmentActivity activity) {
        FragmentManager fm = activity.getSupportFragmentManager();
        FragmentTransaction ft = fm.beginTransaction();
        Fragment prev = fm.findFragmentByTag("dialog_about");
        if (prev != null) {
            ft.remove(prev);
        }
        ft.addToBackStack(null);
        new AboutDialog().show(ft, "dialog_about");
    }

    public static class AboutDialog extends DialogFragment {

        private static final String VERSION_UNAVAILABLE = "N/A";

        public AboutDialog() {
        }

        @Override
        public Dialog onCreateDialog(Bundle savedInstanceState) {
            // Get app version
            PackageManager pm = getActivity().getPackageManager();
            String packageName = getActivity().getPackageName();
            String versionName;
            try {
                PackageInfo info = pm.getPackageInfo(packageName, 0);
                versionName = info.versionName;
            } catch (PackageManager.NameNotFoundException e) {
                versionName = VERSION_UNAVAILABLE;
            }
            // Build the about body view and append the link to see OSS licenses
            SpannableStringBuilder aboutBody = new SpannableStringBuilder();
            aboutBody.append(Html.fromHtml(getString(R.string.about_body, versionName)));
            SpannableString licensesLink = new SpannableString(getString(R.string.about_licenses));
            licensesLink.setSpan(new ClickableSpan() {

                @Override
                public void onClick(View view)

            }, 0, licensesLink.length(), 0);
            aboutBody.append("\n\n");
            aboutBody.append(licensesLink);
            SpannableString eulaLink = new SpannableString(getString(R.string.about_eula));
            eulaLink.setSpan(new ClickableSpan() {

                @Override
                public void onClick(View view) {
                    HelpUtils.showEula(getActivity());
                }
            }, 0, eulaLink.length(), 0);
            aboutBody.append("\n\n");
            aboutBody.append(eulaLink);
            LayoutInflater layoutInflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            TextView aboutBodyView = (TextView) layoutInflater.inflate(R.layout.dialog_about, null);
            aboutBodyView.setText(aboutBody);
            aboutBodyView.setMovementMethod(new LinkMovementMethod());
            return new AlertDialog.Builder(getActivity()).setTitle(R.string.title_about).setView(aboutBodyView).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int whichButton) {
                    dialog.dismiss();
                }
            }).create();
        }
    }

    public static void showOpenSourceLicenses(FragmentActivity activity) {
        FragmentManager fm = activity.getSupportFragmentManager();
        FragmentTransaction ft = fm.beginTransaction();
        Fragment prev = fm.findFragmentByTag("dialog_licenses");
        if (prev != null) {
            ft.remove(prev);
        }
        ft.addToBackStack(null);
        new OpenSourceLicensesDialog().show(ft, "dialog_licenses");
    }

    public static class OpenSourceLicensesDialog extends DialogFragment {

        public OpenSourceLicensesDialog() {
        }

        @Override
        public Dialog onCreateDialog(Bundle savedInstanceState) {
            WebView webView = new WebView(getActivity());
            webView.loadUrl("file:///android_asset/licenses.html");
            return new AlertDialog.Builder(getActivity()).setTitle(R.string.about_licenses).setView(webView).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int whichButton) {
                    dialog.dismiss();
                }
            }).create();
        }
    }

    public static void showEula(FragmentActivity activity) {
        FragmentManager fm = activity.getSupportFragmentManager();
        FragmentTransaction ft = fm.beginTransaction();
        Fragment prev = fm.findFragmentByTag("dialog_eula");
        if (prev != null) {
            ft.remove(prev);
        }
        ft.addToBackStack(null);
        new EulaDialog().show(ft, "dialog_eula");
    }

    public static class EulaDialog extends DialogFragment {

        public EulaDialog() {
        }

        @Override
        public Dialog onCreateDialog(Bundle savedInstanceState) {
            int padding = getResources().getDimensionPixelSize(R.dimen.content_padding_normal);
            TextView eulaTextView = new TextView(getActivity());
            eulaTextView.setText(Html.fromHtml(getString(R.string.eula_text)));
            eulaTextView.setMovementMethod(LinkMovementMethod.getInstance());
            eulaTextView.setPadding(padding, padding, padding, padding);
            return new AlertDialog.Builder(getActivity()).setTitle(R.string.about_eula).setView(eulaTextView).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int whichButton) {
                    dialog.dismiss();
                }
            }).create();
        }
    }
}


package com.funkyandroid.droidcon.uk.iosched.util;

import com.funkyandroid.droidcon.uk.iosched.R;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.text.Html;
import android.text.SpannableString;
import android.text.SpannableStringBuilder;
import android.text.method.LinkMovementMethod;
import android.text.style.ClickableSpan;
import android.view.LayoutInflater;
import android.view.View;
import android.webkit.WebView;
import android.widget.TextView;

/**
 * This is a set of helper methods for showing contextual help information in the app.
 */
public class HelpUtils {

    public static void showAbout(FragmentActivity activity) {
        FragmentManager fm = activity.getSupportFragmentManager();
        FragmentTransaction ft = fm.beginT

        Fragment prev = fm.findFragmentByTag("dialog_about");
        if (prev != null) {
            ft.remove(prev);
        }
        ft.addToBackStack(null);
        new AboutDialog().show(ft, "dialog_about");
    }

    public static class AboutDialog extends DialogFragment {

        private static final String VERSION_UNAVAILABLE = "N/A";

        public AboutDialog() {
        }

        @Override
        public Dialog onCreateDialog(Bundle savedInstanceState) {
            // Get app version
            PackageManager pm = getActivity().getPackageManager();
            String packageName = getActivity().getPackageName();
            String versionName;
            try {
                PackageInfo info = pm.getPackageInfo(packageName, 0);
                versionName = info.versionName;
            } catch (PackageManager.NameNotFoundException e) {
                versionName = VERSION_UNAVAILABLE;
            }
            // Build the about body view and append the link to see OSS licenses
            SpannableStringBuilder aboutBody = new SpannableStringBuilder();
            aboutBody.append(Html.fromHtml(getString(R.string.about_body, versionName)));
            SpannableString licensesLink = new SpannableString(getString(R.string.about_licenses));
            licensesLink.setSpan(new ClickableSpan() {

                @Override
                public void onClick(View view) {
                    HelpUtils.showOpenSourceLicenses(getActivity());
                }
            }, 0, licensesLink.length(), 0);
            aboutBody.append("\n\n");
            aboutBody.append(licensesLink);
            SpannableString eulaLink = new SpannableString(getString(R.string.about_eula));
            eulaLink.setSpan(new ClickableSpan() {

                @Override
                public void onClick(View view) {
                    HelpUtils.showEula(getActivity());
                }
            }, 0, eulaLink.length(), 0);
            aboutBody.append("\n\n");
            aboutBody.append(eulaLink);
            LayoutInflater layoutInflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            TextView aboutBodyView = (TextView) layoutInflater.inflate(R.layout.dialog_about, null);
            aboutBodyView.setText(aboutBody);
            aboutBodyView.setMovementMethod(new LinkMovementMethod());
            return new AlertDialog.Builder(getActivity()).setTitle(R.string.title_about).setView(aboutBodyView).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int whichButton) {
                    dialog.dismiss();
                }
            }).create();
        }
    }

    public static void showOpenSourceLicenses(FragmentActivity activity) {
        FragmentManager fm = activity.getSupportFragmentManager();
        FragmentTransaction ft = fm.beginTransaction();
        Fragment prev = fm.findFragmentByTag("dialog_licenses");
        if (prev != null) {
            ft.remove(prev);
        }
        ft.addToBackStack(null);
        new OpenSourceLicensesDialog().show(ft, "dialog_licenses");
    }

    public static class OpenSourceLicensesDialog extends DialogFragment {

        public OpenSourceLicensesDialog() {
        }

        @Override
        public Dialog onCreateDialog(Bundle savedInstanceState) {
            WebView webView = new WebView(getActivity());
            webView.loadUrl("file:///android_asset/licenses.html");
            return new AlertDialog.Builder(getActivity()).setTitle(R.string.about_licenses).setView(webView).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int whichButton) {
                    dialog.dismiss();
                }
            }).create();
        }
    }

    public static void showEula(FragmentActivity activity) {
        FragmentManager fm = activity.getSupportFragmentManager();
        FragmentTransaction ft = fm.beginTransaction();
        Fragment prev = fm.findFragmentByTag("dialog_eula");
        if (prev != null) {
            ft.remove(prev);
        }
        ft.addToBackStack(null);
        new EulaDialog().show(ft, "dialog_eula");
    }

    public static class EulaDialog extends DialogFragment {

        public EulaDialog() {
        }

        @Override
        public Dialog onCreateDialog(Bundle savedInstanceState) {
            int padding = getResources().getDimensionPixelSize(R.dimen.content_padding_normal);
            TextView eulaTextView = new TextView(getActivity());
            eulaTextView.setText(Html.fromHtml(getString(R.string.eula_text)));
            eulaTextView.setMovementMethod(LinkMovementMethod.getInstance());
            eulaTextView.setPadding(padding, padding, padding, padding);
            return new AlertDialog.Builder(getActivity()).setTitle(R.string.about_eula).setView(eulaTextView).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int whichButton) {
                    dialog.dismiss();
                }
            }).create();
        }
    }
}


try {
                PackageInfo info = pm.getPackageInfo(packageName, 0);
                versionName = info.versionName;
            } catch (PackageManager.NameNotFoundException e) {
                versionName = VERSION_UNAVAILABLE;
            }

package com.funkyandroid.droidcon.uk.iosched.util;

import com.funkyandroid.droidcon.uk.iosched.R;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.text.Html;
import android.text.SpannableString;
import android.text.SpannableStringBuilder;
import android.text.method.LinkMovementMethod;
import android.text.style.ClickableSpan;
import android.view.LayoutInflater;
import android.view.View;
import android.webkit.WebView;
import android.widget.TextView;

/**
 * This is a set of helper methods for showing contextual help information in the app.
 */
public class HelpUtils {

    public static void showAbout(FragmentActivity activity) {
        FragmentManager fm = activity.getSupportFragmentManager();
        FragmentTransaction ft = fm.beginTransaction();
        Fragment prev = fm.findFragmentByTag("dialog_about");
        if (prev != null) {
            ft.remove(prev);
        }
        ft.addToBackStack(null);
        new AboutDialog().show(ft, "dialog_about");
    }

    public static class AboutDialog extends DialogFragment {

        private static final String VERSION_UNAVAILABLE = "N/A";

        public AboutDialog() {
        }

        @Override
        public Dialog onCreateDialog(Bundle savedInstanceState) {
            // Get app version
            PackageManager pm = getActivity().getPackageManager();
            String packageName = getActivity().getPackageName();
            String versionName;

            // Build the about body view and append the link to see OSS licenses
            SpannableStringBuilder aboutBody = new SpannableStringBuilder();
            aboutBody.append(Html.fromHtml(getString(R.string.about_body, versionName)));
            SpannableString licensesLink = new SpannableString(getString(R.string.about_licenses));
            licensesLink.setSpan(new ClickableSpan() {

                @Override
                public void onClick(View view) {
                    HelpUtils.showOpenSourceLicenses(getActivity());
                }
            }, 0, licensesLink.length(), 0);
            aboutBody.append("\n\n");
            aboutBody.append(licensesLink);
            SpannableString eulaLink = new SpannableString(getString(R.string.about_eula));
            eulaLink.setSpan(new ClickableSpan() {

                @Override
                public void onClick(View view) {
                    HelpUtils.showEula(getActivity());
                }
            }, 0, eulaLink.length(), 0);
            aboutBody.append("\n\n");
            aboutBody.append(eulaLink);
            LayoutInflater layoutInflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            TextView aboutBodyView = (TextView) layoutInflater.inflate(R.layout.dialog_about, null);
            aboutBodyView.setText(aboutBody);
            aboutBodyView.setMovementMethod(new LinkMovementMethod());
            return new AlertDialog.Builder(getActivity()).setTitle(R.string.title_about).setView(aboutBodyView).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int whichButton) {
                    dialog.dismiss();
                }
            }).create();
        }
    }

    public static void showOpenSourceLicenses(FragmentActivity activity) {
        FragmentManager fm = activity.getSupportFragmentManager();
        FragmentTransaction ft = fm.beginTransaction();
        Fragment prev = fm.findFragmentByTag("dialog_licenses");
        if (prev != null) {
            ft.remove(prev);
        }
        ft.addToBackStack(null);
        new OpenSourceLicensesDialog().show(ft, "dialog_licenses");
    }

    public static class OpenSourceLicensesDialog extends DialogFragment {

        public OpenSourceLicensesDialog() {
        }

        @Override
        public Dialog onCreateDialog(Bundle savedInstanceState) {
            WebView webView = new WebView(getActivity());
            webView.loadUrl("file:///android_asset/licenses.html");
            return new AlertDialog.Builder(getActivity()).setTitle(R.string.about_licenses).setView(webView).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int whichButton) {
                    dialog.dismiss();
                }
            }).create();
        }
    }

    public static void showEula(FragmentActivity activity) {
        FragmentManager fm = activity.getSupportFragmentManager();
        FragmentTransaction ft = fm.beginTransaction();
        Fragment prev = fm.findFragmentByTag("dialog_eula");
        if (prev != null) {
            ft.remove(prev);
        }
        ft.addToBackStack(null);
        new EulaDialog().show(ft, "dialog_eula");
    }

    public static class EulaDialog extends DialogFragment {

        public EulaDialog() {
        }

        @Override
        public Dialog onCreateDialog(Bundle savedInstanceState) {
            int padding = getResources().getDimensionPixelSize(R.dimen.content_padding_normal);
            TextView eulaTextView = new TextView(getActivity());
            eulaTextView.setText(Html.fromHtml(getString(R.string.eula_text)));
            eulaTextView.setMovementMethod(LinkMovementMethod.getInstance());
            eulaTextView.setPadding(padding, padding, padding, padding);
            return new AlertDialog.Builder(getActivity()).setTitle(R.string.about_eula).setView(eulaTextView).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int whichButton) {
                    dialog.dismiss();
                }
            }).create();
        }
    }
}


public Builder setTransferredBytes(long transferredBytes)

package org.eclipse.aether.transfer;

import java.nio.ByteBuffer;
import static java.util.Objects.requireNonNull;
import org.eclipse.aether.RepositorySystemSession;

/**
 * An event fired to a transfer listener during an artifact/metadata transfer.
 *
 * @see TransferListener
 * @see TransferEvent.Builder
 */
public final class TransferEvent {

    /**
     * The type of the event.
     */
    public enum EventType {

        /**
         * @see TransferListener#transferInitiated(TransferEvent)
         */
        INITIATED,
        /**
         * @see TransferListener#transferStarted(TransferEvent)
         */
        STARTED,
        /**
         * @see TransferListener#transferProgressed(TransferEvent)
         */
        PROGRESSED,
        /**
         * @see TransferListener#transferCorrupted(TransferEvent)
         */
        CORRUPTED,
        /**
         * @see TransferListener#transferSucceeded(TransferEvent)
         */
        SUCCEEDED,
        /**
         * @see TransferListener#transferFailed(TransferEvent)
         */
        FAILED
    }

    /**
     * The type of the request/transfer being performed.
     */
    public enum RequestType {

        GET,
        /**
         * Check artifact/metadata existence only.
         */
        GET_EXISTENCE,
        PUT
    }

    private final EventType type;

    private final RequestType requestType;

    private final RepositorySystemSession session;

    private final TransferResource resource;

    private final ByteBuffer dataBuffer;

    private final long transferredBytes;

    private final Exception exception;

    TransferEvent(Builder builder) {
        type = builder.type;
        requestType = builder.requestType;
        session = builder.session;
        resource = builder.resource;
        dataBuffer = builder.dataBuffer;
        transferredBytes = builder.transferredBytes;
        exception = builder.exception;
    }

    /**
     * Gets the type of the event.
     *
     * @return The type of the event, never {@code null}.
     */
    public EventType getType() {
        return type;
    }

    /**
     * Gets the type of the request/transfer.
     *
     * @return The type of the request/transfer, never {@code null}.
     */
    public RequestType getRequestType() {
        return requestType;
    }

    /**
     * Gets the repository system session during which the event occurred.
     *
     * @return The repository system session during which the event occurred, never {@code null}.
     */
    public RepositorySystemSession getSession() {
        return session;
    }

    /**
     * Gets the resource that is being transferred.
     *
     * @return The resource being transferred, never {@code null}.
     */
    public TransferResource getResource() {
        return resource;
    }

    /**
     * Gets the total number of bytes that have been transferred since the download/upload of the resource was started.
     * If a download has been resumed, the returned count includes the bytes that were already downloaded during the
     * previous attempt. In other words, the ratio of transferred bytes to the content length of the resource indicates
     * the percentage of transfer completion.
     *
     * @return The total number of bytes that have been transferred since the transfer started, never negative.
     * @see #getDataLength()
     * @see TransferResource#getResumeOffset()
     */
    public long getTransferredBytes() {
        return transferredBytes;
    }

    /**
     * Gets the byte buffer holding the transferred bytes since the last event. A listener must assume this buffer to be
     * owned by the event source and must not change any byte in this buffer. Also, the buffer is only valid for the
     * duration of the event callback, i.e. the next event might reuse the same buffer (with updated contents).
     * Therefore, if the actual event processing is deferred, the byte buffer would have to be cloned to create an
     * immutable snapshot of its contents.
     *
     * @return The (read-only) byte buffer or {@code null} if not applicable to the event, i.e. if the event type is not
     *         {@link EventType#PROGRESSED}.
     */
    public ByteBuffer getDataBuffer() {
        return (dataBuffer != null) ? dataBuffer.asReadOnlyBuffer() : null;
    }

    /**
     * Gets the number of bytes that have been transferred since the last event.
     *
     * @return The number of bytes that have been transferred since the last event, possibly zero but never negative.
     * @see #getTransferredBytes()
     */
    public int getDataLength() {
        return (dataBuffer != null) ? dataBuffer.remaining() : 0;
    }

    /**
     * Gets the error that occurred during the transfer.
     *
     * @return The error that occurred or {@code null} if none.
     */
    public Exception getException() {
        return exception;
    }

    @Override
    public String toString() {
        return getRequestType() + " " + getType() + " " + getResource();
    }

    /**
     * A builder to create transfer events.
     */
    public static final class Builder {

        EventType type;

        RequestType requestType;

        final RepositorySystemSession session;

        final TransferResource resource;

        ByteBuffer dataBuffer;

        long transferredBytes;

        Exception exception;

        /**
         * Creates a new transfer event builder for the specified session and the given resource.
         *
         * @param session The repository system session, must not be {@code null}.
         * @param resource The resource being transferred, must not be {@code null}.
         */
        public Builder(RepositorySystemSession session, TransferResource resource) {
            this.session = requireNonNull(session, "repository system session cannot be null");
            this.resource = requireNonNull(resource, "transfer resource cannot be null");
            type = EventType.INITIATED;
            requestType = RequestType.GET;
        }

        private Builder(Builder prototype) {
            session = prototype.session;
            resource = prototype.resource;
            type = prototype.type;
            requestType = prototype.requestType;
            dataBuffer = prototype.dataBuffer;
            transferredBytes = prototype.transferredBytes;
            exception = prototype.exception;
        }

        /**
         * Creates a new transfer event builder from the current values of this builder. The state of this builder
         * remains unchanged.
         *
         * @return The new event builder, never {@code null}.
         */
        public Builder copy() {
            return new Builder(this);
        }

        /**
         * Sets the type of the event and resets event-specific fields. In more detail, the data buffer and the
         * exception fields are set to {@code null}. Furthermore, the total number of transferred bytes is set to
         * {@code 0} if the event type is {@link EventType#STARTED}.
         *
         * @param type The type of the event, must not be {@code null}.
         * @return This event builder for chaining, never {@code null}.
         */
        public Builder resetType(EventType type) {
            this.type = requireNonNull(type, "event type cannot be null");
            dataBuffer = null;
            exception = null;
            switch(type) {
                case INITIATED:
                case STARTED:
                    transferredBytes = 0L;
                default:
            }
            return this;
        }

        /**
         * Sets the type of the event. When re-using the same builder to generate a sequence of events for one transfer,
         * {@link #resetType(TransferEvent.EventType)} might be more handy.
         *
         * @param type The type of the event, must not be {@code null}.
         * @return This event builder for chaining, never {@code null}.
         */
        public Builder setType(EventType type) {
            this.type = requireNonNull(type, "event type cannot be null");
            return this;
        }

        /**
         * Sets the type of the request/transfer.
         *
         * @param requestType The request/transfer type, must not be {@code null}.
         * @return This event builder for chaining, never {@code null}.
         */
        public Builder setRequestType(RequestType requestType) {
            this.requestType = requireNonNull(requestType, "request type cannot be null");
            return this;
        }

        /**
         * Sets the total number of bytes that have been transferred so far during the download/upload of the resource.
         * If a download is being resumed, the count must include the bytes that were already downloaded in the previous
         * attempt and from which the current transfer started. In this case, the event type {@link EventType#STARTED}
         * should indicate from what byte the download resumes.
         *
         * @param transferredBytes The total number of bytes that have been transferred so far during the
         *            download/upload of the resource, must not be negative.
         * @return This event builder for chaining, never {@code null}.
         * @see TransferResource#setResumeOffset(long)
         */

{
            if (transferredBytes < 0L) {
                throw new IllegalArgumentException("number of transferred bytes cannot be negative");
            }
            this.transferredBytes = transferredBytes;
            return this;
        }

        /**
         * Increments the total number of bytes that have been transferred so far during the download/upload.
         *
         * @param transferredBytes The number of bytes that have been transferred since the last event, must not be
         *            negative.
         * @return This event builder for chaining, never {@code null}.
         */
        public Builder addTransferredBytes(long transferredBytes) {
            if (transferredBytes < 0L) {
                throw new IllegalArgumentException("number of transferred bytes cannot be negative");
            }
            this.transferredBytes += transferredBytes;
            return this;
        }

        /**
         * Sets the byte buffer holding the transferred bytes since the last event.
         *
         * @param buffer The byte buffer holding the transferred bytes since the last event, may be {@code null} if not
         *            applicable to the event.
         * @param offset The starting point of valid bytes in the array.
         * @param length The number of valid bytes, must not be negative.
         * @return This event builder for chaining, never {@code null}.
         */
        public Builder setDataBuffer(byte[] buffer, int offset, int length) {
            return setDataBuffer((buffer != null) ? ByteBuffer.wrap(buffer, offset, length) : null);
        }

        /**
         * Sets the byte buffer holding the transferred bytes since the last event.
         *
         * @param dataBuffer The byte buffer holding the transferred bytes since the last event, may be {@code null} if
         *            not applicable to the event.
         * @return This event builder for chaining, never {@code null}.
         */
        public Builder setDataBuffer(ByteBuffer dataBuffer) {
            this.dataBuffer = dataBuffer;
            return this;
        }

        /**
         * Sets the error that occurred during the transfer.
         *
         * @param exception The error that occurred during the transfer, may be {@code null} if none.
         * @return This event builder for chaining, never {@code null}.
         */
        public Builder setException(Exception exception) {
            this.exception = exception;
            return this;
        }

        /**
         * Builds a new transfer event from the current values of this builder. The state of the builder itself remains
         * unchanged.
         *
         * @return The transfer event, never {@code null}.
         */
        public TransferEvent build() {
            return new TransferEvent(this);
        }
    }
}


{
            this.requestType = requireNonNull(requestType, "request type cannot be null");
            return this;
        }

package org.eclipse.aether.transfer;

import java.nio.ByteBuffer;
import static java.util.Objects.requireNonNull;
import org.eclipse.aether.RepositorySystemSession;

/**
 * An event fired to a transfer listener during an artifact/metadata transfer.
 *
 * @see TransferListener
 * @see TransferEvent.Builder
 */
public final class TransferEvent {

    /**
     * The type of the event.
     */
    public enum EventType {

        /**
         * @see TransferListener#transferInitiated(TransferEvent)
         */
        INITIATED,
        /**
         * @see TransferListener#transferStarted(TransferEvent)
         */
        STARTED,
        /**
         * @see TransferListener#transferProgressed(TransferEvent)
         */
        PROGRESSED,
        /**
         * @see TransferListener#transferCorrupted(TransferEvent)
         */
        CORRUPTED,
        /**
         * @see TransferListener#transferSucceeded(TransferEvent)
         */
        SUCCEEDED,
        /**
         * @see TransferListener#transferFailed(TransferEvent)
         */
        FAILED
    }

    /**
     * The type of the request/transfer being performed.
     */
    public enum RequestType {

        GET,
        /**
         * Check artifact/metadata existence only.
         */
        GET_EXISTENCE,
        PUT
    }

    private final EventType type;

    private final RequestType requestType;

    private final RepositorySystemSession session;

    private final TransferResource resource;

    private final ByteBuffer dataBuffer;

    private final long transferredBytes;

    private final Exception exception;

    TransferEvent(Builder builder) {
        type = builder.type;
        requestType = builder.requestType;
        session = builder.session;
        resource = builder.resource;
        dataBuffer = builder.dataBuffer;
        transferredBytes = builder.transferredBytes;
        exception = builder.exception;
    }

    /**
     * Gets the type of the event.
     *
     * @return The type of the event, never {@code null}.
     */
    public EventType getType() {
        return type;
    }

    /**
     * Gets the type of the request/transfer.
     *
     * @return The type of the request/transfer, never {@code null}.
     */
    public RequestType getRequestType() {
        return requestType;
    }

    /**
     * Gets the repository system session during which the event occurred.
     *
     * @return The repository system session during which the event occurred, never {@code null}.
     */
    public RepositorySystemSession getSession() {
        return session;
    }

    /**
     * Gets the resource that is being transferred.
     *
     * @return The resource being transferred, never {@code null}.
     */
    public TransferResource getResource() {
        return resource;
    }

    /**
     * Gets the total number of bytes that have been transferred since the download/upload of the resource was started.
     * If a download has been resumed, the returned count includes the bytes that were already downloaded during the
     * previous attempt. In other words, the ratio of transferred bytes to the content length of the resource indicates
     * the percentage of transfer completion.
     *
     * @return The total number of bytes that have been transferred since the transfer started, never negative.
     * @see #getDataLength()
     * @see TransferResource#getResumeOffset()
     */
    public long getTransferredBytes() {
        return transferredBytes;
    }

    /**
     * Gets the byte buffer holding the transferred bytes since the last event. A listener must assume this buffer to be
     * owned by the event source and must not change any byte in this buffer. Also, the buffer is only valid for the
     * duration of the event callback, i.e. the next event might reuse the same buffer (with updated contents).
     * Therefore, if the actual event processing is deferred, the byte buffer would have to be cloned to create an
     * immutable snapshot of its contents.
     *
     * @return The (read-only) byte buffer or {@code null} if not applicable to the event, i.e. if the event type is not
     *         {@link EventType#PROGRESSED}.
     */
    public ByteBuffer getDataBuffer() {
        return (dataBuffer != null) ? dataBuffer.asReadOnlyBuffer() : null;
    }

    /**
     * Gets the number of bytes that have been transferred since the last event.
     *
     * @return The number of bytes that have been transferred since the last event, possibly zero but never negative.
     * @see #getTransferredBytes()
     */
    public int getDataLength() {
        return (dataBuffer != null) ? dataBuffer.remaining() : 0;
    }

    /**
     * Gets the error that occurred during the transfer.
     *
     * @return The error that occurred or {@code null} if none.
     */
    public Exception getException() {
        return exception;
    }

    @Override
    public String toString() {
        return getRequestType() + " " + getType() + " " + getResource();
    }

    /**
     * A builder to create transfer events.
     */
    public static final class Builder {

        EventType type;

        RequestType requestType;

        final RepositorySystemSession session;

        final TransferResource resource;

        ByteBuffer dataBuffer;

        long transferredBytes;

        Exception exception;

        /**
         * Creates a new transfer event builder for the specified session and the given resource.
         *
         * @param session The repository system session, must not be {@code null}.
         * @param resource The resource being transferred, must not be {@code null}.
         */
        public Builder(RepositorySystemSession session, TransferResource resource) {
            this.session = requireNonNull(session, "repository system session cannot be null");
            this.resource = requireNonNull(resource, "transfer resource cannot be null");
            type = EventType.INITIATED;
            requestType = RequestType.GET;
        }

        private Builder(Builder prototype) {
            session = prototype.session;
            resource = prototype.resource;
            type = prototype.type;
            requestType = prototype.requestType;
            dataBuffer = prototype.dataBuffer;
            transferredBytes = prototype.transferredBytes;
            exception = prototype.exception;
        }

        /**
         * Creates a new transfer event builder from the current values of this builder. The state of this builder
         * remains unchanged.
         *
         * @return The new event builder, never {@code null}.
         */
        public Builder copy() {
            return new Builder(this);
        }

        /**
         * Sets the type of the event and resets event-specific fields. In more detail, the data buffer and the
         * exception fields are set to {@code null}. Furthermore, the total number of transferred bytes is set to
         * {@code 0} if the event type is {@link EventType#STARTED}.
         *
         * @param type The type of the event, must not be {@code null}.
         * @return This event builder for chaining, never {@code null}.
         */
        public Builder resetType(EventType type) {
            this.type = requireNonNull(type, "event type cannot be null");
            dataBuffer = null;
            exception = null;
            switch(type) {
                case INITIATED:
                case STARTED:
                    transferredBytes = 0L;
                default:
            }
            return this;
        }

        /**
         * Sets the type of the event. When re-using the same builder to generate a sequence of events for one transfer,
         * {@link #resetType(TransferEvent.EventType)} might be more handy.
         *
         * @param type The type of the event, must not be {@code null}.
         * @return This event builder for chaining, never {@code null}.
         */
        public Builder setType(EventType type) {
            this.type = requireNonNull(type, "event type cannot be null");
            return this;
        }

        /**
         * Sets the type of the request/transfer.
         *
         * @param requestType The request/transfer type, must not be {@code null}.
         * @return This event builder for chaining, never {@code null}.
         */
        public Builder setRequestType(RequestType requestType)

        /**
         * Sets the total number of bytes that have been transferred so far during the download/upload of the resource.
         * If a download is being resumed, the count must include the bytes that were already downloaded in the previous
         * attempt and from which the current transfer started. In this case, the event type {@link EventType#STARTED}
         * should indicate from what byte the download resumes.
         *
         * @param transferredBytes The total number of bytes that have been transferred so far during the
         *            download/upload of the resource, must not be negative.
         * @return This event builder for chaining, never {@code null}.
         * @see TransferResource#setResumeOffset(long)
         */
        public Builder setTransferredBytes(long transferredBytes) {
            if (transferredBytes < 0L) {
                throw new IllegalArgumentException("number of transferred bytes cannot be negative");
            }
            this.transferredBytes = transferredBytes;
            return this;
        }

        /**
         * Increments the total number of bytes that have been transferred so far during the download/upload.
         *
         * @param transferredBytes The number of bytes that have been transferred since the last event, must not be
         *            negative.
         * @return This event builder for chaining, never {@code null}.
         */
        public Builder addTransferredBytes(long transferredBytes) {
            if (transferredBytes < 0L) {
                throw new IllegalArgumentException("number of transferred bytes cannot be negative");
            }
            this.transferredBytes += transferredBytes;
            return this;
        }

        /**
         * Sets the byte buffer holding the transferred bytes since the last event.
         *
         * @param buffer The byte buffer holding the transferred bytes since the last event, may be {@code null} if not
         *            applicable to the event.
         * @param offset The starting point of valid bytes in the array.
         * @param length The number of valid bytes, must not be negative.
         * @return This event builder for chaining, never {@code null}.
         */
        public Builder setDataBuffer(byte[] buffer, int offset, int length) {
            return setDataBuffer((buffer != null) ? ByteBuffer.wrap(buffer, offset, length) : null);
        }

        /**
         * Sets the byte buffer holding the transferred bytes since the last event.
         *
         * @param dataBuffer The byte buffer holding the transferred bytes since the last event, may be {@code null} if
         *            not applicable to the event.
         * @return This event builder for chaining, never {@code null}.
         */
        public Builder setDataBuffer(ByteBuffer dataBuffer) {
            this.dataBuffer = dataBuffer;
            return this;
        }

        /**
         * Sets the error that occurred during the transfer.
         *
         * @param exception The error that occurred during the transfer, may be {@code null} if none.
         * @return This event builder for chaining, never {@code null}.
         */
        public Builder setException(Exception exception) {
            this.exception = exception;
            return this;
        }

        /**
         * Builds a new transfer event from the current values of this builder. The state of the builder itself remains
         * unchanged.
         *
         * @return The transfer event, never {@code null}.
         */
        public TransferEvent build() {
            return new TransferEvent(this);
        }
    }
}


package org.eclipse.aether.transfer;

import java.nio.ByteBuffer;
import static java.util.Objects.requireNonNull;
import org.eclipse.aether.RepositorySystemSession;

/**
 * An event fired to a transfer listener during an artifact/metadata transfer.
 *
 * @see TransferListener
 * @see TransferEvent.Builder
 */
public final class TransferEvent {

    /**
     * The type of the event.
     */
    public enum EventType {

        /**
         * @see TransferListener#transferInitiated(TransferEvent)
         */
        INITIATED,
        /**
         * @see TransferListener#transferStarted(TransferEvent)
         */
        STARTED,
        /**
         * @see TransferListener#transferProgressed(TransferEvent)
         */
        PROGRESSED,
        /**
         * @see TransferListener#transferCorrupted(TransferEvent)
         */
        CORRUPTED,
        /**
         * @see TransferListener#transferSucceeded(TransferEvent)
         */
        SUCCEEDED,
        /**
         * @see TransferListener#transferFailed(TransferEvent)
         */
        FAILED
    }

    /**
     * The type of the request/transfer being performed.
     */
    public enum RequestType {

        GET,
        /**
         * Check artifact/metadata existence only.
         */
        GET_EXISTENCE,
        PUT
    }

    private final EventType type;

    private final RequestType requestType;

    private final RepositorySystemSession session;

    private final TransferResource resource;

    private final ByteBuffer dataBuffer;

    private final long transferredBytes;

    private final Exception exception;

    TransferEvent(Builder builder) {
        type = builder.type;
        requestType = builder.requestType;
        session = builder.session;
        resource = builder.resource;
        dataBuffer = builder.dataBuffer;
        transferredBytes = builder.transferredBytes;
        exception = builder.exception;
    }

    /**
     * Gets the type of the event.
     *
     * @return The type of the event, never {@code null}.
     */
    public EventType getType() {
        return type;
    }

    /**
     * Gets the type of the request/transfer.
     *
     * @return The type of the request/transfer, never {@code null}.
     */
    public RequestType getRequestType() {
        return requestType;
    }

    /**
     * Gets the repository system session during which the event occurred.
     *
     * @return The repository system session during which the event occurred, never {@code null}.
     */
    public RepositorySystemSession getSession() {
        return session;
    }

    /**
     * Gets the resource that is being transferred.
     *
     * @return The resource being transferred, never {@code null}.
     */
    public TransferResource getResource() {
        return resource;
    }

    /**
     * Gets the total number of bytes that have been transferred since the download/upload of the resource was started.
     * If a download has been resumed, the returned count includes the bytes that were already downloaded during the
     * previous attempt. In other words, the ratio of transferred bytes to the content length of the resource indicates
     * the percentage of transfer completion.
     *
     * @return The total number of bytes that have been transferred since the transfer started, never negative.
     * @see #getDataLength()
     * @see TransferResource#getResumeOffset()
     */
    public long getTransferredBytes() {
        return transferredBytes;
    }

    /**
     * Gets the byte buffer holding the transferred bytes since the last event. A listener must assume this buffer to be
     * owned by the event source and must not change any byte in this buffer. Also, the buffer is only valid for the
     * duration of the event callback, i.e. the next event might reuse the same buffer (with updated contents).
     * Therefore, if the actual event processing is deferred, the byte buffer would have to be cloned to create an
     * immutable snapshot of its contents.
     *
     * @return The (read-only) byte buffer or {@code null} if not applicable to the event, i.e. if the event type is not
     *         {@link EventType#PROGRESSED}.
     */
    public ByteBuffer getDataBuffer() {
        return (dataBuffer != null) ? dataBuffer.asReadOnlyBuffer() : null;
    }

    /**
     * Gets the number of bytes that have been transferred since the last event.
     *
     * @return The number of bytes that have been transferred since the last event, possibly zero but never negative.
     * @see #getTransferredBytes()
     */
    public int getDataLength() {
        return (dataBuffer != null) ? dataBuffer.remaining() : 0;
    }

    /**
     * Gets the error that occurred during the transfer.
     *
     * @return The error that occurred or {@code null} if none.
     */
    public Exception getException() {
        return exception;
    }

    @Override
    public String toString() {
        return getRequestType() + " " + getType() + " " + getResource();
    }

    /**
     * A builder to create transfer events.
     */
    public static final class Builder {

        EventType type;

        RequestType requestType;

        final RepositorySystemSession session;

        final TransferResource resource;

        ByteBuffer dataBuffer;

        long transferredBytes;

        Exception exception;

        /**
         * Creates a new transfer event builder for the specified session and the given resource.
         *
         * @param session The repository system session, must not be {@code null}.
         * @param resource The resource being transferred, must not be {@code null}.
         */
        public Builder(RepositorySystemSession session, TransferResource resource) {
            this.session = requireNonNull(session, "repository system session cannot be null");
            this.resource = requireNonNull(resource, "transfer resource cannot be null");
            type = EventType.INITIATED;
            requestType = RequestType.GET;
        }

        private Builder(Builder prototype) {
            session = prototype.session;
            resource = prototype.resource;
            type = prototype.type;
            requestType = prototype.requestType;
            dataBuffer = prototype.dataBuffer;
            transferredBytes = prototype.transferredBytes;
            exception = prototype.exception;
        }

        /**
         * Creates a new transfer event builder from the current values of this builder. The state of this builder
         * remains unchanged.
         *
         * @return The new event builder, never {@code null}.
         */
        public Builder copy() {
            return new Builder(this);
        }

        /**
         * Sets the type of the event and resets event-specific fields. In more detail, the data buffer and the
         * exception fields are set to {@code null}. Furthermore, the total number of transferred bytes is set to
         * {@code 0} if the event type is {@link EventType#STARTED}.
         *
         * @param type The type of the event, must not be {@code null}.
         * @return This event builder for chaining, never {@code null}.
         */
        public Builder resetType(EventType type) {
            this.type = requireNonNull(type, "event type cannot be null");
            dataBuffer = null;
            exception = null;
            switch(type) {
                case INITIATED:
                case STARTED:
                    transferredBytes = 0L;
                default:
            }
            return this;
        }

        /**
         * Sets the type of the event. When re-using the same builder to generate a sequence of events for one transfer,
         * {@link #resetType(TransferEvent.EventType)} might be more handy.
         *
         * @param type The type of the event, must not be {@code null}.
         * @return This event builder for chaining, never {@code null}.
         */
        public Builder setType(EventType type) {
            this.type = requireNonNull(type, "event type cannot be null");
            return this;
        }

        /**
         * Sets the type of the request/transfer.
         *
         * @param requestType The request/transfer type, must not be {@code null}.
         * @return This event builder for chaining, never {@code null}.
         */
        public Builder setRequestType(RequestType requestType) {
            this.requestType = requireNonNull(requestType, "request type cannot be null");
            return this;
        }

        /**
         * Sets the total number of bytes that have been transferred so far during the download/upload of the resource.
         * If a download is being resumed, the count must include the bytes that were already downloaded in the previous
         * attempt and from which the current transfer started. In this case, the event type {@link EventType#STARTED}
         * should indicate from what byte the download resumes.
         *
         * @param transferredBytes The total number of bytes that have been transferred so far during the
         *            download/upload of the resource, must not be negative.
         * @return This event builder for chaining, never {@code null}.
         * @see TransferResource#setResumeOffset(long)
         */
        public Builder setTransferredBytes(long transferredBytes) {
            if (transferredBytes < 0L) {
                throw new IllegalArgumentException("number of transferred bytes cannot be negative");
            }
            this.transferredBytes = transferredBytes;
            return this;
        }

        /**
         * Increments the total number of bytes that have been transferred so far during the download/upload.
         *
         * @param transferredBytes The number of bytes that have been transferred since the last event, must not be
         *            negative.
         * @return This event builder for chaining, never {@code null}.
         */
        public Builder addTransferredBytes(long transferredBytes) {
            if (transferredBytes < 0L) {
                throw new IllegalArgumentException("number of transferred bytes cannot be negative");
            }
            this.transferredBytes += transferredBytes;
            return thi

        }

        /**
         * Sets the byte buffer holding the transferred bytes since the last event.
         *
         * @param buffer The byte buffer holding the transferred bytes since the last event, may be {@code null} if not
         *            applicable to the event.
         * @param offset The starting point of valid bytes in the array.
         * @param length The number of valid bytes, must not be negative.
         * @return This event builder for chaining, never {@code null}.
         */
        public Builder setDataBuffer(byte[] buffer, int offset, int length) {
            return setDataBuffer((buffer != null) ? ByteBuffer.wrap(buffer, offset, length) : null);
        }

        /**
         * Sets the byte buffer holding the transferred bytes since the last event.
         *
         * @param dataBuffer The byte buffer holding the transferred bytes since the last event, may be {@code null} if
         *            not applicable to the event.
         * @return This event builder for chaining, never {@code null}.
         */
        public Builder setDataBuffer(ByteBuffer dataBuffer) {
            this.dataBuffer = dataBuffer;
            return this;
        }

        /**
         * Sets the error that occurred during the transfer.
         *
         * @param exception The error that occurred during the transfer, may be {@code null} if none.
         * @return This event builder for chaining, never {@code null}.
         */
        public Builder setException(Exception exception) {
            this.exception = exception;
            return this;
        }

        /**
         * Builds a new transfer event from the current values of this builder. The state of the builder itself remains
         * unchanged.
         *
         * @return The transfer event, never {@code null}.
         */
        public TransferEvent build() {
            return new TransferEvent(this);
        }
    }
}


public Builder setRequestType(RequestType requestType) {
            this.requestType = requireNonNull(requestType, "request type cannot be null");
            return this;
        }

package org.eclipse.aether.transfer;

import java.nio.ByteBuffer;
import static java.util.Objects.requireNonNull;
import org.eclipse.aether.RepositorySystemSession;

/**
 * An event fired to a transfer listener during an artifact/metadata transfer.
 *
 * @see TransferListener
 * @see TransferEvent.Builder
 */
public final class TransferEvent {

    /**
     * The type of the event.
     */
    public enum EventType {

        /**
         * @see TransferListener#transferInitiated(TransferEvent)
         */
        INITIATED,
        /**
         * @see TransferListener#transferStarted(TransferEvent)
         */
        STARTED,
        /**
         * @see TransferListener#transferProgressed(TransferEvent)
         */
        PROGRESSED,
        /**
         * @see TransferListener#transferCorrupted(TransferEvent)
         */
        CORRUPTED,
        /**
         * @see TransferListener#transferSucceeded(TransferEvent)
         */
        SUCCEEDED,
        /**
         * @see TransferListener#transferFailed(TransferEvent)
         */
        FAILED
    }

    /**
     * The type of the request/transfer being performed.
     */
    public enum RequestType {

        GET,
        /**
         * Check artifact/metadata existence only.
         */
        GET_EXISTENCE,
        PUT
    }

    private final EventType type;

    private final RequestType requestType;

    private final RepositorySystemSession session;

    private final TransferResource resource;

    private final ByteBuffer dataBuffer;

    private final long transferredBytes;

    private final Exception exception;

    TransferEvent(Builder builder) {
        type = builder.type;
        requestType = builder.requestType;
        session = builder.session;
        resource = builder.resource;
        dataBuffer = builder.dataBuffer;
        transferredBytes = builder.transferredBytes;
        exception = builder.exception;
    }

    /**
     * Gets the type of the event.
     *
     * @return The type of the event, never {@code null}.
     */
    public EventType getType() {
        return type;
    }

    /**
     * Gets the type of the request/transfer.
     *
     * @return The type of the request/transfer, never {@code null}.
     */
    public RequestType getRequestType() {
        return requestType;
    }

    /**
     * Gets the repository system session during which the event occurred.
     *
     * @return The repository system session during which the event occurred, never {@code null}.
     */
    public RepositorySystemSession getSession() {
        return session;
    }

    /**
     * Gets the resource that is being transferred.
     *
     * @return The resource being transferred, never {@code null}.
     */
    public TransferResource getResource() {
        return resource;
    }

    /**
     * Gets the total number of bytes that have been transferred since the download/upload of the resource was started.
     * If a download has been resumed, the returned count includes the bytes that were already downloaded during the
     * previous attempt. In other words, the ratio of transferred bytes to the content length of the resource indicates
     * the percentage of transfer completion.
     *
     * @return The total number of bytes that have been transferred since the transfer started, never negative.
     * @see #getDataLength()
     * @see TransferResource#getResumeOffset()
     */
    public long getTransferredBytes() {
        return transferredBytes;
    }

    /**
     * Gets the byte buffer holding the transferred bytes since the last event. A listener must assume this buffer to be
     * owned by the event source and must not change any byte in this buffer. Also, the buffer is only valid for the
     * duration of the event callback, i.e. the next event might reuse the same buffer (with updated contents).
     * Therefore, if the actual event processing is deferred, the byte buffer would have to be cloned to create an
     * immutable snapshot of its contents.
     *
     * @return The (read-only) byte buffer or {@code null} if not applicable to the event, i.e. if the event type is not
     *         {@link EventType#PROGRESSED}.
     */
    public ByteBuffer getDataBuffer() {
        return (dataBuffer != null) ? dataBuffer.asReadOnlyBuffer() : null;
    }

    /**
     * Gets the number of bytes that have been transferred since the last event.
     *
     * @return The number of bytes that have been transferred since the last event, possibly zero but never negative.
     * @see #getTransferredBytes()
     */
    public int getDataLength() {
        return (dataBuffer != null) ? dataBuffer.remaining() : 0;
    }

    /**
     * Gets the error that occurred during the transfer.
     *
     * @return The error that occurred or {@code null} if none.
     */
    public Exception getException() {
        return exception;
    }

    @Override
    public String toString() {
        return getRequestType() + " " + getType() + " " + getResource();
    }

    /**
     * A builder to create transfer events.
     */
    public static final class Builder {

        EventType type;

        RequestType requestType;

        final RepositorySystemSession session;

        final TransferResource resource;

        ByteBuffer dataBuffer;

        long transferredBytes;

        Exception exception;

        /**
         * Creates a new transfer event builder for the specified session and the given resource.
         *
         * @param session The repository system session, must not be {@code null}.
         * @param resource The resource being transferred, must not be {@code null}.
         */
        public Builder(RepositorySystemSession session, TransferResource resource) {
            this.session = requireNonNull(session, "repository system session cannot be null");
            this.resource = requireNonNull(resource, "transfer resource cannot be null");
            type = EventType.INITIATED;
            requestType = RequestType.GET;
        }

        private Builder(Builder prototype) {
            session = prototype.session;
            resource = prototype.resource;
            type = prototype.type;
            requestType = prototype.requestType;
            dataBuffer = prototype.dataBuffer;
            transferredBytes = prototype.transferredBytes;
            exception = prototype.exception;
        }

        /**
         * Creates a new transfer event builder from the current values of this builder. The state of this builder
         * remains unchanged.
         *
         * @return The new event builder, never {@code null}.
         */
        public Builder copy() {
            return new Builder(this);
        }

        /**
         * Sets the type of the event and resets event-specific fields. In more detail, the data buffer and the
         * exception fields are set to {@code null}. Furthermore, the total number of transferred bytes is set to
         * {@code 0} if the event type is {@link EventType#STARTED}.
         *
         * @param type The type of the event, must not be {@code null}.
         * @return This event builder for chaining, never {@code null}.
         */
        public Builder resetType(EventType type) {
            this.type = requireNonNull(type, "event type cannot be null");
            dataBuffer = null;
            exception = null;
            switch(type) {
                case INITIATED:
                case STARTED:
                    transferredBytes = 0L;
                default:
            }
            return this;
        }

        /**
         * Sets the type of the event. When re-using the same builder to generate a sequence of events for one transfer,
         * {@link #resetType(TransferEvent.EventType)} might be more handy.
         *
         * @param type The type of the event, must not be {@code null}.
         * @return This event builder for chaining, never {@code null}.
         */
        public Builder setType(EventType type) {
            this.type = requireNonNull(type, "event type cannot be null");
            return this;
        }

        /**
         * Sets the type of the request/transfer.
         *
         * @param requestType The request/transfer type, must not be {@code null}.
         * @return This event builder for chaining, never {@code null}.
         */


switch(type) {
                case INITIATED:
                case STARTED:
                    transferredBytes = 0L;
                default:
            }

package org.eclipse.aether.transfer;

import java.nio.ByteBuffer;
import static java.util.Objects.requireNonNull;
import org.eclipse.aether.RepositorySystemSession;

/**
 * An event fired to a transfer listener during an artifact/metadata transfer.
 *
 * @see TransferListener
 * @see TransferEvent.Builder
 */
public final class TransferEvent {

    /**
     * The type of the event.
     */
    public enum EventType {

        /**
         * @see TransferListener#transferInitiated(TransferEvent)
         */
        INITIATED,
        /**
         * @see TransferListener#transferStarted(TransferEvent)
         */
        STARTED,
        /**
         * @see TransferListener#transferProgressed(TransferEvent)
         */
        PROGRESSED,
        /**
         * @see TransferListener#transferCorrupted(TransferEvent)
         */
        CORRUPTED,
        /**
         * @see TransferListener#transferSucceeded(TransferEvent)
         */
        SUCCEEDED,
        /**
         * @see TransferListener#transferFailed(TransferEvent)
         */
        FAILED
    }

    /**
     * The type of the request/transfer being performed.
     */
    public enum RequestType {

        GET,
        /**
         * Check artifact/metadata existence only.
         */
        GET_EXISTENCE,
        PUT
    }

    private final EventType type;

    private final RequestType requestType;

    private final RepositorySystemSession session;

    private final TransferResource resource;

    private final ByteBuffer dataBuffer;

    private final long transferredBytes;

    private final Exception exception;

    TransferEvent(Builder builder) {
        type = builder.type;
        requestType = builder.requestType;
        session = builder.session;
        resource = builder.resource;
        dataBuffer = builder.dataBuffer;
        transferredBytes = builder.transferredBytes;
        exception = builder.exception;
    }

    /**
     * Gets the type of the event.
     *
     * @return The type of the event, never {@code null}.
     */
    public EventType getType() {
        return type;
    }

    /**
     * Gets the type of the request/transfer.
     *
     * @return The type of the request/transfer, never {@code null}.
     */
    public RequestType getRequestType() {
        return requestType;
    }

    /**
     * Gets the repository system session during which the event occurred.
     *
     * @return The repository system session during which the event occurred, never {@code null}.
     */
    public RepositorySystemSession getSession() {
        return session;
    }

    /**
     * Gets the resource that is being transferred.
     *
     * @return The resource being transferred, never {@code null}.
     */
    public TransferResource getResource() {
        return resource;
    }

    /**
     * Gets the total number of bytes that have been transferred since the download/upload of the resource was started.
     * If a download has been resumed, the returned count includes the bytes that were already downloaded during the
     * previous attempt. In other words, the ratio of transferred bytes to the content length of the resource indicates
     * the percentage of transfer completion.
     *
     * @return The total number of bytes that have been transferred since the transfer started, never negative.
     * @see #getDataLength()
     * @see TransferResource#getResumeOffset()
     */
    public long getTransferredBytes() {
        return transferredBytes;
    }

    /**
     * Gets the byte buffer holding the transferred bytes since the last event. A listener must assume this buffer to be
     * owned by the event source and must not change any byte in this buffer. Also, the buffer is only valid for the
     * duration of the event callback, i.e. the next event might reuse the same buffer (with updated contents).
     * Therefore, if the actual event processing is deferred, the byte buffer would have to be cloned to create an
     * immutable snapshot of its contents.
     *
     * @return The (read-only) byte buffer or {@code null} if not applicable to the event, i.e. if the event type is not
     *         {@link EventType#PROGRESSED}.
     */
    public ByteBuffer getDataBuffer() {
        return (dataBuffer != null) ? dataBuffer.asReadOnlyBuffer() : null;
    }

    /**
     * Gets the number of bytes that have been transferred since the last event.
     *
     * @return The number of bytes that have been transferred since the last event, possibly zero but never negative.
     * @see #getTransferredBytes()
     */
    public int getDataLength() {
        return (dataBuffer != null) ? dataBuffer.remaining() : 0;
    }

    /**
     * Gets the error that occurred during the transfer.
     *
     * @return The error that occurred or {@code null} if none.
     */
    public Exception getException() {
        return exception;
    }

    @Override
    public String toString() {
        return getRequestType() + " " + getType() + " " + getResource();
    }

    /**
     * A builder to create transfer events.
     */
    public static final class Builder {

        EventType type;

        RequestType requestType;

        final RepositorySystemSession session;

        final TransferResource resource;

        ByteBuffer dataBuffer;

        long transferredBytes;

        Exception exception;

        /**
         * Creates a new transfer event builder for the specified session and the given resource.
         *
         * @param session The repository system session, must not be {@code null}.
         * @param resource The resource being transferred, must not be {@code null}.
         */
        public Builder(RepositorySystemSession session, TransferResource resource) {
            this.session = requireNonNull(session, "repository system session cannot be null");
            this.resource = requireNonNull(resource, "transfer resource cannot be null");
            type = EventType.INITIATED;
            requestType = RequestType.GET;
        }

        private Builder(Builder prototype) {
            session = prototype.session;
            resource = prototype.resource;
            type = prototype.type;
            requestType = prototype.requestType;
            dataBuffer = prototype.dataBuffer;
            transferredBytes = prototype.transferredBytes;
            exception = prototype.exception;
        }

        /**
         * Creates a new transfer event builder from the current values of this builder. The state of this builder
         * remains unchanged.
         *
         * @return The new event builder, never {@code null}.
         */
        public Builder copy() {
            return new Builder(this);
        }

        /**
         * Sets the type of the event and resets event-specific fields. In more detail, the data buffer and the
         * exception fields are set to {@code null}. Furthermore, the total number of transferred bytes is set to
         * {@code 0} if the event type is {@link EventType#STARTED}.
         *
         * @param type The type of the event, must not be {@code null}.
         * @return This event builder for chaining, never {@code null}.
         */
        public Builder resetType(EventType type) {
            this.type = requireNonNull(type, "event type cannot be null");
            dataBuffer = null;
            exception = null;

            return this;
        }

        /**
         * Sets the type of the event. When re-using the same builder to generate a sequence of events for one transfer,
         * {@link #resetType(TransferEvent.EventType)} might be more handy.
         *
         * @param type The type of the event, must not be {@code null}.
         * @return This event builder for chaining, never {@code null}.
         */
        public Builder setType(EventType type) {
            this.type = requireNonNull(type, "event type cannot be null");
            return this;
        }

        /**
         * Sets the type of the request/transfer.
         *
         * @param requestType The request/transfer type, must not be {@code null}.
         * @return This event builder for chaining, never {@code null}.
         */
        public Builder setRequestType(RequestType requestType) {
            this.requestType = requireNonNull(requestType, "request type cannot be null");
            return this;
        }

        /**
         * Sets the total number of bytes that have been transferred so far during the download/upload of the resource.
         * If a download is being resumed, the count must include the bytes that were already downloaded in the previous
         * attempt and from which the current transfer started. In this case, the event type {@link EventType#STARTED}
         * should indicate from what byte the download resumes.
         *
         * @param transferredBytes The total number of bytes that have been transferred so far during the
         *            download/upload of the resource, must not be negative.
         * @return This event builder for chaining, never {@code null}.
         * @see TransferResource#setResumeOffset(long)
         */
        public Builder setTransferredBytes(long transferredBytes) {
            if (transferredBytes < 0L) {
                throw new IllegalArgumentException("number of transferred bytes cannot be negative");
            }
            this.transferredBytes = transferredBytes;
            return this;
        }

        /**
         * Increments the total number of bytes that have been transferred so far during the download/upload.
         *
         * @param transferredBytes The number of bytes that have been transferred since the last event, must not be
         *            negative.
         * @return This event builder for chaining, never {@code null}.
         */
        public Builder addTransferredBytes(long transferredBytes) {
            if (transferredBytes < 0L) {
                throw new IllegalArgumentException("number of transferred bytes cannot be negative");
            }
            this.transferredBytes += transferredBytes;
            return this;
        }

        /**
         * Sets the byte buffer holding the transferred bytes since the last event.
         *
         * @param buffer The byte buffer holding the transferred bytes since the last event, may be {@code null} if not
         *            applicable to the event.
         * @param offset The starting point of valid bytes in the array.
         * @param length The number of valid bytes, must not be negative.
         * @return This event builder for chaining, never {@code null}.
         */
        public Builder setDataBuffer(byte[] buffer, int offset, int length) {
            return setDataBuffer((buffer != null) ? ByteBuffer.wrap(buffer, offset, length) : null);
        }

        /**
         * Sets the byte buffer holding the transferred bytes since the last event.
         *
         * @param dataBuffer The byte buffer holding the transferred bytes since the last event, may be {@code null} if
         *            not applicable to the event.
         * @return This event builder for chaining, never {@code null}.
         */
        public Builder setDataBuffer(ByteBuffer dataBuffer) {
            this.dataBuffer = dataBuffer;
            return this;
        }

        /**
         * Sets the error that occurred during the transfer.
         *
         * @param exception The error that occurred during the transfer, may be {@code null} if none.
         * @return This event builder for chaining, never {@code null}.
         */
        public Builder setException(Exception exception) {
            this.exception = exception;
            return this;
        }

        /**
         * Builds a new transfer event from the current values of this builder. The state of the builder itself remains
         * unchanged.
         *
         * @return The transfer event, never {@code null}.
         */
        public TransferEvent build() {
            return new TransferEvent(this);
        }
    }
}


package com.android.settings.homepage.contextualcards;

import android.content.Context;
import android.database.Cursor;

/**
 * Feature provider for the contextual card feature.
 */
public interface ContextualCardFeatureProvider {

    /**
     * Get contextual cards from the card provider
     */

    /**
     * Mark a specific {@link ContextualCard} as dismissed with dismissal signal in the database
     * to indicate that the card has been dismissed.
     *
     * @param context  Context
     * @param cardName The card name of the ContextualCard which is dismissed by user.
     * @return The number of rows updated
     */
    int markCardAsDismissed(Context context, String cardName);
}


@SuppressWarnings("unused")
    private void postUpdate(Object entity)

/**
 * ****************************************************************************
 *
 *  Contributors:
 *      IBM Corporation - initial API and implementation
 * *****************************************************************************
 */
package com.ibm.ws.jpa.fvt.callback.listeners.defaultlistener;

import com.ibm.ws.jpa.fvt.callback.AbstractCallbackListener;

public class DefaultCallbackListenerPrivate extends AbstractCallbackListener {

    private final static DefaultCallbackListenerPrivate _singleton = new DefaultCallbackListenerPrivate();

    public final static AbstractCallbackListener getSingleton() {
        return _singleton;
    }

    public final static void reset() {
        _singleton.resetCallbackData();
    }

    @SuppressWarnings("unused")
    private void prePersist(Object entity) {
        _singleton.doPrePersist(ProtectionType.PT_PRIVATE);
    }

    @SuppressWarnings("unused")
    private void postPersist(Object entity) {
        _singleton.doPostPersist(ProtectionType.PT_PRIVATE);
    }

    @SuppressWarnings("unused")
    private void preUpdate(Object entity) {
        _singleton.doPreUpdate(ProtectionType.PT_PRIVATE);
    }

{
        _singleton.doPostUpdate(ProtectionType.PT_PRIVATE);
    }

    @SuppressWarnings("unused")
    private void preRemove(Object entity) {
        _singleton.doPreRemove(ProtectionType.PT_PRIVATE);
    }

    @SuppressWarnings("unused")
    private void postRemove(Object entity) {
        _singleton.doPostRemove(ProtectionType.PT_PRIVATE);
    }

    @SuppressWarnings("unused")
    private void postLoad(Object entity) {
        _singleton.doPostLoad(ProtectionType.PT_PRIVATE);
    }
}


{
        _singleton.resetCallbackData();
    }

/**
 * ****************************************************************************
 *
 *  Contributors:
 *      IBM Corporation - initial API and implementation
 * *****************************************************************************
 */
package com.ibm.ws.jpa.fvt.callback.listeners.defaultlistener;

import com.ibm.ws.jpa.fvt.callback.AbstractCallbackListener;

public class DefaultCallbackListenerPrivate extends AbstractCallbackListener {

    private final static DefaultCallbackListenerPrivate _singleton = new DefaultCallbackListenerPrivate();

    public final static AbstractCallbackListener getSingleton() {
        return _singleton;
    }

    public final static void reset()

    @SuppressWarnings("unused")
    private void prePersist(Object entity) {
        _singleton.doPrePersist(ProtectionType.PT_PRIVATE);
    }

    @SuppressWarnings("unused")
    private void postPersist(Object entity) {
        _singleton.doPostPersist(ProtectionType.PT_PRIVATE);
    }

    @SuppressWarnings("unused")
    private void preUpdate(Object entity) {
        _singleton.doPreUpdate(ProtectionType.PT_PRIVATE);
    }

    @SuppressWarnings("unused")
    private void postUpdate(Object entity) {
        _singleton.doPostUpdate(ProtectionType.PT_PRIVATE);
    }

    @SuppressWarnings("unused")
    private void preRemove(Object entity) {
        _singleton.doPreRemove(ProtectionType.PT_PRIVATE);
    }

    @SuppressWarnings("unused")
    private void postRemove(Object entity) {
        _singleton.doPostRemove(ProtectionType.PT_PRIVATE);
    }

    @SuppressWarnings("unused")
    private void postLoad(Object entity) {
        _singleton.doPostLoad(ProtectionType.PT_PRIVATE);
    }
}


/**
 * ****************************************************************************
 *
 *  Contributors:
 *      IBM Corporation - initial API and implementation
 * *****************************************************************************
 */
package com.ibm.ws.jpa.fvt.callback.listeners.defaultlistener;

import com.ibm.ws.jpa.fvt.callback.AbstractCallbackListener;

public class DefaultCallbackListenerPrivate extends AbstractCallbackListener {

    private final static DefaultCallbackListenerPrivate _singleton = new DefaultCallbackListenerPrivate();

    public final static AbstractCallbackListener getSingleton() {
        return _singleton;
    }

    public final static void reset() {
        _singleton.resetCallbackData();
    }

    @SuppressWarnings("unused")
    private void prePersist(Object entity) {
        _singleton.doPrePersist(ProtectionType.PT_PRIVATE);
    }

    @SuppressWarnings("unused")
    private void postPersist(Object entity) {
        _singleton.doPostPersist(ProtectionType.PT_PRIVATE);
    }

    @SuppressWarnings("unused")
    private void preUpdate(Object entity) {
        _singleton.doPreUpdate(ProtectionType.PT_PRIVATE);
    }

    @SuppressWarnings("unused")
    private void postUpdate(Object entity) {
        _singleton.doPostUpdate(ProtectionType.PT_PRIVATE);
    }

    @SuppressWarnings("unused")
    private void preRemove(Object entity) {
        _s

    }

    @SuppressWarnings("unused")
    private void postRemove(Object entity) {
        _singleton.doPostRemove(ProtectionType.PT_PRIVATE);
    }

    @SuppressWarnings("unused")
    private void postLoad(Object entity) {
        _singleton.doPostLoad(ProtectionType.PT_PRIVATE);
    }
}


package io.pravega.common.util;

import java.util.function.Consumer;

/**
 * Defines an Index that orders its IndexEntries by an Int64 (long) Key.
 *

 * Notes:
 *

 *
 Implementations of this interface are not necessarily thread-safe and no assumptions should be made about
 * multi-thread consistency.
 *
 No implementation of this class should be able to index null values. As such, for all the retrieval methods,
 * a null value can be safely interpreted as no result found.
 *

 *
 * @param <V> The type of the IndexEntries.
 */
public interface SortedIndex<V extends SortedIndex.IndexEntry> {

    /**
     * Clears the contents of the Index.
     */
    void clear();

    /**
     * Inserts the given item into the Index. If there already exists an item with the same key, it will be overridden.
     *
     * @param item The item to insert.
     * @return The displaced item, if any.
     */
    V put(V item);

    /**
     * Removes any item with the given key from the Index.
     *
     * @param key The key of the item to remove.
     * @return The removed item, or null if nothing was removed.
     */
    V remove(long key);

    /**
     * Gets a value indicating the number of items in the Index.
     *
     * @return Integer indicating the size or number of items in the Index.
     */
    int size();

    /**
     * Gets an item with the given key.
     *
     * @param key The key to search by.
     * @return The requested item, if it exists, or null if it doesn't.
     */
    V get(long key);

    /**
     * Gets the smallest item whose key is greater than or equal to the given key.
     *
     * @param key the Key to search by.
     * @return The sought item, or null if it doesn't exist.
     */

    /**
     * Gets the largest item whose key is smaller than or equal to the given key.
     *
     * @param key the Key to search by.
     * @return The sought item, or null if it doesn't exist.
     */
    V getFloor(long key);

    /**
     * Gets the smallest item in the index.
     *
     * @return The sought item, or null (if no items in the index).
     */
    V getFirst();

    /**
     * Gets the largest item in the index.
     *
     * @return The sought item, or null (if no items in the index).
     */
    V getLast();

    /**
     * Iterates through each item in the Index, in natural order, and calls the given consumer on all of them.
     *
     * @param consumer The consumer to invoke.
     * @throws java.util.ConcurrentModificationException If the Index is modified while this method is executing.
     */
    void forEach(Consumer<V> consumer);

    /**
     * Defines a generic entry into an Index.
     */
    interface IndexEntry {

        /**
         * Gets a value representing the key of the entry. The Key should not change for the lifetime of the entry and
         * should be very cheap to return (as it is used very frequently).
         *
         * @return The entry key.
         */
        long key();
    }
}


public default List<MenuEntry> getViews(final HttpServletRequest request, final Object object)

/**
 * ****************************************************************************
 *
 *  Contributors:
 *      IBH SYSTEMS GmbH - initial API and implementation
 * *****************************************************************************
 */
package org.eclipse.packagedrone.web.common;

import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.eclipse.packagedrone.web.common.menu.MenuEntry;

public interface InterfaceExtender {

    public default List<MenuEntry> getActions(final HttpServletRequest request, final Object object) {
        return null;
    }

{
        return null;
    }

    public default List<MenuEntry> getMainMenuEntries(final HttpServletRequest request) {
        return null;
    }
}


/**
 * ****************************************************************************
 *
 *  Contributors:
 *      IBH SYSTEMS GmbH - initial API and implementation
 * *****************************************************************************
 */
package org.eclipse.packagedrone.web.common;

import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.eclipse.packagedrone.web.common.menu.MenuEntry;

public interface InterfaceExtender {

    public default List<MenuEntry> getActions(final HttpServletRequest request, final Object object) {
        return null;
    }

    public default List<MenuEntry> getViews(final HttpServletRequest request, final Object object) {
        return null;
    }

    public default List<MenuEntry> getMainMenuEntries(final HttpServletRequest request)


/**
 * ****************************************************************************
 *
 *  Contributors:
 *      IBH SYSTEMS GmbH - initial API and implementation
 * *****************************************************************************
 */
package org.eclipse.packagedrone.web.common;

import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.eclipse.packagedrone.web.common.menu.MenuEntry;

public interface InterfaceExtender {

    public default List<MenuEntry> getActions(final HttpServletRequest request, final Object object) {
        ret

    }

    public default List<MenuEntry> getViews(final HttpServletRequest request, final Object object) {
        return null;
    }

    public default List<MenuEntry> getMainMenuEntries(final HttpServletRequest request) {
        return null;
    }
}


@Scheduled(fixedDelay = 300 * 1000)
    public void updatePowerOutBandStatusScheduler()

package io.rackshift.job;

import io.rackshift.constants.RackHDConstants;
import io.rackshift.mybatis.domain.BareMetal;
import io.rackshift.mybatis.domain.BareMetalExample;
import io.rackshift.mybatis.domain.OutBand;
import io.rackshift.mybatis.domain.OutBandExample;
import io.rackshift.mybatis.mapper.BareMetalMapper;
import io.rackshift.mybatis.mapper.OutBandMapper;
import io.rackshift.service.RackHDService;
import io.rackshift.utils.IPMIUtil;
import io.rackshift.utils.LogUtil;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.time.Duration;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;

/**
 * ipmi定时扫描任务 更新物理机开关机状态 已经新添加物理机到ipmi被动发现
 */
@Service
public class SyncOutBandJob {

    @Resource
    private OutBandMapper outBandMapper;

    @Resource
    private BareMetalMapper bareMetalMapper;

    @Resource
    private RackHDService rackHDService;

{
        // 测试每一个自发现机器带外的连通性，并且查看是否有物理机关联该带外ip（手动导入，不存在mac地址的只是视为信息纳管和基本开关机流程控制，因此不需要同步至物理机和RackHD）
        LocalDateTime before = LocalDateTime.now();
        LogUtil.info(String.format("开始带外物理机状态更新 标记%s：时间：%s", before.getDayOfMonth(), before.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:MM:SS"))));
        OutBandExample pmOutBandExample = new OutBandExample();
        List<OutBand> pmOutBandList = outBandMapper.selectByExample(pmOutBandExample);
        if (pmOutBandList.size() == 0) {
            return;
        }
        updatePowerOutBandStatus(pmOutBandList);
        LocalDateTime now = LocalDateTime.now();
        LogUtil.info(String.format("结束开始带外物理机状态更新 标记%s：时间：%s,总共耗时:%s秒", before.getDayOfMonth(), now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:MM:SS")), Duration.between(before, now).getSeconds()));
    }

    public void updatePowerOutBandStatus(List<OutBand> pmOutBandList) {
        if (CollectionUtils.isNotEmpty(pmOutBandList)) {
            pmOutBandList.forEach(o -> {
                IPMIUtil.Account account = new IPMIUtil.Account(o.getIp(), o.getUserName(), o.getPwd());
                // 找出对应ip的mac地址的物理机把mac地址回写到带外
                BareMetalExample pmExample = new BareMetalExample();
                pmExample.createCriteria().andIdEqualTo(o.getBareMetalId());
                List<BareMetal> pms = bareMetalMapper.selectByExample(pmExample);
                try {
                    // ip存在但是账号密码为空
                    if (StringUtils.isAnyBlank(account.getHost(), account.getUserName(), account.getPwd())) {
                        setStatusBeforeIPMI(o, pms, RackHDConstants.PM_OUT_BAND_UNKNOW);
                        return;
                    }
                    String ipmiResult = IPMIUtil.exeCommand(account, "power status");
                    o.setStatus(RackHDConstants.PM_OUT_BAND_ON);
                    outBandMapper.updateByPrimaryKeySelective(o);
                    if (pms.size() > 0) {
                        // 根据ipmi请求的返回结果判断物理机是开机还是关机状态
                        pms.stream().forEach(p -> {
                            // 同时更新物理机的mac地址到带外列表
                            o.setMac(p.getBmcMac());
                            outBandMapper.updateByPrimaryKey(o);
                            updatePmStatusInfo(ipmiResult, p);
                            String nodeId = p.getServerId();
                            if (StringUtils.isBlank(nodeId)) {
                                return;
                            }
                            if (rackHDService.createOrUpdateObm(o, p))
                                return;
                        });
                    }
                } catch (Exception e) {
                    setStatusBeforeIPMI(o, pms, RackHDConstants.PM_OUT_BAND_OFF);
                }
            });
        }
    }

    private void setStatusBeforeIPMI(OutBand o, List<BareMetal> pms, String outBandStatus) {
        o.setStatus(outBandStatus);
        outBandMapper.updateByPrimaryKeySelective(o);
        pms.stream().forEach(p -> {
            updatePmStatusInfo(RackHDConstants.PM_POWER_UNKNOWN, p);
        });
        return;
    }

    private void updatePmStatusInfo(String ipmiResult, BareMetal machine) {
        // 返回结果一般是 Chassis power on/off
        if (StringUtils.isNotBlank(ipmiResult) && ipmiResult.contains(RackHDConstants.PM_POWER_ON)) {
            machine.setPower(RackHDConstants.PM_POWER_ON);
        } else if (StringUtils.isNotBlank(ipmiResult) && ipmiResult.contains(RackHDConstants.PM_POWER_OFF)) {
            machine.setPower(RackHDConstants.PM_POWER_OFF);
        } else {
            machine.setPower(RackHDConstants.PM_POWER_UNKNOWN);
        }
        bareMetalMapper.updateByPrimaryKeySelective(machine);
    }
}