<commit_before>package com.yatatsu.autobundle;

import android.app.Fragment;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;

/**
 * Injection helper.
 * resolve each binding class for target.
 */
public final class AutoBundle {

    /**
     * tag for {@link Log}
     */
    private static final String TAG = "AutoBundle";

    /**
     * {@link AutoBundleBinder} implementation class will be generated by apt.
     * So if {@link Arg} does not used, impl class may not exist.
     */
    static final String BINDER_CLASS_NAME = "com.yatatsu.autobundle.AutoBundleBindingDispatcher";

    /**
     * static instance will load at the first time static method called.
     */
    private static AutoBundleBinder autoBundleBinder;

    private AutoBundle() {
        throw new AssertionError("no instances");
    }

    /**
     * assign arguments to target fields.
     *
     * target may be {@link android.app.Activity},
     * {@link android.content.BroadcastReceiver},
     * {@link android.app.Service},
     * {@link android.app.Fragment} or these compatibility class.
     *
     * @param target target which has {@link Arg} annotated fields.
     * @param args source bundle.
     */
    public static void bind(Object target, Bundle args) {
        AutoBundleBinder binder = findBinder();
        if (binder != null) {
            binder.bind(target, args);
        } else {
            Log.w(TAG, "AutoBundle cannot resolve binding with " + target.getClass());
        }
    }

    /**
     * assign to target fields from {@link Intent#getExtras()}.
     *
     * target may be {@link android.app.Activity},
     * {@link android.content.BroadcastReceiver},
     * {@link android.app.Service} or these compatibility class.
     *
     * @param target target which has {@link Arg} annotated fields.
     * @param intent source bundle.
     */
    public static void bind(Object target, Intent intent) {
        AutoBundleBinder binder = findBinder();
        if (binder != null) {
            binder.bind(target, intent);
        } else {
            Log.w(TAG, "AutoBundle cannot resolve binding with " + target.getClass());
        }
    }

    /**
     * assign to target fields from {@link Fragment#getArguments()}.
     *
     * target may be {@link Fragment} or compat.
     *
     * @param target target Fragment which has {@link Arg} annotated fields.
     */
    public static void bind(Object target) {
        AutoBundleBinder binder = findBinder();
        if (binder != null) {
            binder.bind(target);
        } else {
            Log.w(TAG, "AutoBundle cannot resolve binding with " + target.getClass());
        }
    }

    /**
     * set arguments from source fields.
     *
     * target may be {@link android.app.Activity},
     * {@link android.content.BroadcastReceiver},
     * {@link android.app.Service},
     * {@link android.app.Fragment} or these compatibility class.
     *
     * @param source source instance which has {@link Arg} annotated fields.
     * @param args target bundle.
     */
    public static void pack(Object source, Bundle args) {
        AutoBundleBinder binder = findBinder();
        if (binder != null) {
            binder.pack(source, args);
        } else {
            Log.w(TAG, "AutoBundle cannot resolve binding with " + source.getClass());
        }
    }

    static AutoBundleBinder findBinder() {<commit_msg>Add static method `AutoBundle.bind(Activity activity)`<commit_after>package com.yatatsu.autobundle;

import android.app.Activity;
import android.app.Fragment;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;

/**
 * Injection helper.
 * resolve each binding class for target.
 */
public final class AutoBundle {

    /**
     * tag for {@link Log}
     */
    private static final String TAG = "AutoBundle";

    /**
     * {@link AutoBundleBinder} implementation class will be generated by apt.
     * So if {@link Arg} does not used, impl class may not exist.
     */
    static final String BINDER_CLASS_NAME = "com.yatatsu.autobundle.AutoBundleBindingDispatcher";

    /**
     * static instance will load at the first time static method called.
     */
    private static AutoBundleBinder autoBundleBinder;

    private AutoBundle() {
        throw new AssertionError("no instances");
    }

    /**
     * assign to target fields from {@link Activity#getIntent()}
     * @param activity target activity which has {@link Arg} annotated fields.
     */
    public static void bind(Activity activity) {
        bind(activity, activity.getIntent());
    }

    /**
     * assign to target fields from {@link Fragment#getArguments()}.
     *
     * target may be {@link Fragment} or compat.
     *
     * @param target target Fragment which has {@link Arg} annotated fields.
     */
    public static void bind(Object target) {
        AutoBundleBinder binder = findBinder();
        if (binder != null) {
            binder.bind(target);
        } else {
            Log.w(TAG, "AutoBundle cannot resolve binding with " + target.getClass());
        }
    }

    /**
     * assign arguments to target fields.
     *
     * target may be {@link android.app.Activity},
     * {@link android.content.BroadcastReceiver},
     * {@link android.app.Service},
     * {@link android.app.Fragment} or these compatibility class.
     *
     * @param target target which has {@link Arg} annotated fields.
     * @param args source bundle.
     */
    public static void bind(Object target, Bundle args) {
        AutoBundleBinder binder = findBinder();
        if (binder != null) {
            binder.bind(target, args);
        } else {
            Log.w(TAG, "AutoBundle cannot resolve binding with " + target.getClass());
        }
    }

    /**
     * assign to target fields from {@link Intent#getExtras()}.
     *
     * target may be {@link android.app.Activity},
     * {@link android.content.BroadcastReceiver},
     * {@link android.app.Service} or these compatibility class.
     *
     * @param target target which has {@link Arg} annotated fields.
     * @param intent source bundle.
     */
    public static void bind(Object target, Intent intent) {
        AutoBundleBinder binder = findBinder();
        if (binder != null) {
            binder.bind(target, intent);
        } else {
            Log.w(TAG, "AutoBundle cannot resolve binding with " + target.getClass());
        }
    }

    /**
     * set arguments from source fields.
     *
     * target may be {@link android.app.Activity},
     * {@link android.content.BroadcastReceiver},
     * {@link android.app.Service},
     * {@link android.app.Fragment} or these compatibility class.
     *
     * @param source source instance which has {@link Arg} annotated fields.
     * @param args target bundle.
     */
    public static void pack(Object source, Bundle args) {
        AutoBundleBinder binder = findBinder();
        if (binder != null) {
            binder.pack(source, args);
        } else {
            Log.w(TAG, "AutoBundle cannot resolve binding with " + source.getClass());
        }
    }

    static AutoBundleBinder findBinder() {
{'fraction_non_alphanumeric': 0.11022853957636566, 'fraction_numerical': 0.0, 'mean_word_length': 2.398200757575758, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5831670', 'n_tokens_mistral': 1971, 'n_tokens_neox': 1916, 'n_words': 628}