当前位置: 首页>>代码示例>>Java>>正文


Java Function.apply方法代码示例

本文整理汇总了Java中com.annimon.stream.function.Function.apply方法的典型用法代码示例。如果您正苦于以下问题:Java Function.apply方法的具体用法?Java Function.apply怎么用?Java Function.apply使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.annimon.stream.function.Function的用法示例。


在下文中一共展示了Function.apply方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: comparing

import com.annimon.stream.function.Function; //导入方法依赖的package包/类
/**
 * Returns a comparator that uses a function that extracts a sort key
 * to be compared with the specified comparator.
 *
 * @param <T> the type of the objects compared by the comparator
 * @param <U> the type of the sort key
 * @param keyExtractor  the function that extracts the sort key
 * @param keyComparator  the comparator used to compare the sort key
 * @return a comparator
 * @throws NullPointerException if {@code keyExtractor} or {@code keyComparator} is null
 */
public static <T, U> ComparatorCompat<T> comparing(
        final Function<? super T, ? extends U> keyExtractor,
        final Comparator<? super U> keyComparator) {
    Objects.requireNonNull(keyExtractor);
    Objects.requireNonNull(keyComparator);
    return new ComparatorCompat<T>(new Comparator<T>() {

        @Override
        public int compare(T t1, T t2) {
            final U u1 = keyExtractor.apply(t1);
            final U u2 = keyExtractor.apply(t2);
            return keyComparator.compare(u1, u2);
        }
    });
}
 
开发者ID:aNNiMON,项目名称:Lightweight-Stream-API,代码行数:27,代码来源:ComparatorCompat.java

示例2: encode

import com.annimon.stream.function.Function; //导入方法依赖的package包/类
@NonNull
static String encode(@NonNull Function<Integer, Character> lookup, int number) {
	int loopCounter = 0;
	boolean done = false;

	String str = "";

	while(!done) {
		str = str + lookup.apply(((number >> (4 * loopCounter)) & 0x0f) | randomByte());
		done = number < (Math.pow(16, loopCounter + 1));
		loopCounter++;
	}

	return str;
}
 
开发者ID:rapid-io,项目名称:rapid-io-android,代码行数:16,代码来源:Encode.java

示例3: findView

import com.annimon.stream.function.Function; //导入方法依赖的package包/类
/**
 * Function to find a view and act on it
 *
 * @param view      - The root view
 * @param resId     - The view resource ID to find
 * @param consumer - The method to act with
 * @return T - Instance of the view found, null if not found.
 */
public static <T> T findView(View view, int resId, Function<View, T> caster, Consumer<T> consumer) {
    View child = view.findViewById(resId);
    if (CommonUtils.isNull(child))
        return null;

    T casted = caster.apply(child);
    consumer.accept(casted);
    return casted;
}
 
开发者ID:amitassaraf,项目名称:bull,代码行数:18,代码来源:CommonView.java

示例4: initPokemonGOApi

import com.annimon.stream.function.Function; //导入方法依赖的package包/类
private void initPokemonGOApi(final Function<Object, Object> callback){
        final String authJson = pref.getString("auth", "");

        if(TextUtils.isEmpty(authJson)){
            askLogin();
            return;
        }

        AsyncTask at = new AsyncTask() {

            @Override
            protected void onPreExecute() {
                super.onPreExecute();
//                mSignin.setEnabled(false);
                mSignin.setText(R.string.loading_);
            }

            @Override
            protected Object doInBackground(Object[] objects) {

                try {
                    if(!TextUtils.isEmpty(authJson)){
                        Gson gson = new Gson();

                        final RequestEnvelopeOuterClass.RequestEnvelope.AuthInfo auth =
                                gson.fromJson(authJson, RequestEnvelopeOuterClass.RequestEnvelope.AuthInfo.class);
                        pokemonGo = new PokemonGo(new CredentialProviderAdapter(auth), http);
                        PlayerProfile profile = pokemonGo.getPlayerProfile();
                        return profile;
                    }
                }catch (Exception e){
                    e.printStackTrace();
//                    final String error = e.getMessage();
//                    runOnUiThread(new Runnable() {
//                        @Override
//                        public void run() {
//                            showMessage(error);
//                        }
//                    });
                }
                return null;
            }

            @Override
            protected void onPostExecute(Object o) {
                super.onPostExecute(o);
//                mSignin.setEnabled(false);
                mSignin.setText(R.string.sign_in);
                if(o instanceof  PlayerProfile){
                    PlayerProfile playerProfile = (PlayerProfile)o;
                    renderProfile(playerProfile);
                }else{
                    setProfile("", "", Collections.<String, String>emptyMap());
                }

                if(callback != null){
                    callback.apply(o);
                }

            }
        };
        at.execute();
    }
 
开发者ID:kiideveloper,项目名称:pokiimap-human,代码行数:64,代码来源:PokeMapsActivity.java

示例5: custom

import com.annimon.stream.function.Function; //导入方法依赖的package包/类
/**
 * Applies custom operator on {@code Exceptional}.
 *
 * @param <R> the type of the result
 * @param function  a transforming function
 * @return a result of the transforming function
 * @throws NullPointerException if {@code function} is null
 * @since 1.1.9
 */
public <R> R custom(Function<Exceptional<T>, R> function) {
    Objects.requireNonNull(function);
    return function.apply(this);
}
 
开发者ID:aNNiMON,项目名称:Lightweight-Stream-API,代码行数:14,代码来源:Exceptional.java

示例6: custom

import com.annimon.stream.function.Function; //导入方法依赖的package包/类
/**
 * Applies custom operator on {@code OptionalDouble}.
 *
 * @param <R> the type of the result
 * @param function  a transforming function
 * @return a result of the transforming function
 * @throws NullPointerException if {@code function} is null
 * @since 1.1.9
 */
public <R> R custom(Function<OptionalDouble, R> function) {
    Objects.requireNonNull(function);
    return function.apply(this);
}
 
开发者ID:aNNiMON,项目名称:Lightweight-Stream-API,代码行数:14,代码来源:OptionalDouble.java

示例7: custom

import com.annimon.stream.function.Function; //导入方法依赖的package包/类
/**
 * Applies custom operator on {@code OptionalBoolean}.
 *
 * @param <R> the type of the result
 * @param function  a transforming function
 * @return a result of the transforming function
 * @throws NullPointerException if {@code function} is null
 * @since 1.1.9
 */
public <R> R custom(Function<OptionalBoolean, R> function) {
    Objects.requireNonNull(function);
    return function.apply(this);
}
 
开发者ID:aNNiMON,项目名称:Lightweight-Stream-API,代码行数:14,代码来源:OptionalBoolean.java

示例8: custom

import com.annimon.stream.function.Function; //导入方法依赖的package包/类
/**
 * Applies custom operator on {@code OptionalInt}.
 *
 * @param <R> the type of the result
 * @param function  a transforming function
 * @return a result of the transforming function
 * @throws NullPointerException if {@code function} is null
 * @since 1.1.9
 */
public <R> R custom(Function<OptionalInt, R> function) {
    Objects.requireNonNull(function);
    return function.apply(this);
}
 
开发者ID:aNNiMON,项目名称:Lightweight-Stream-API,代码行数:14,代码来源:OptionalInt.java

示例9: custom

import com.annimon.stream.function.Function; //导入方法依赖的package包/类
/**
 * Applies custom operator on {@code OptionalLong}.
 *
 * @param <R> the type of the result
 * @param function  a transforming function
 * @return a result of the transforming function
 * @throws NullPointerException if {@code function} is null
 * @since 1.1.9
 */
public <R> R custom(Function<OptionalLong, R> function) {
    Objects.requireNonNull(function);
    return function.apply(this);
}
 
开发者ID:aNNiMON,项目名称:Lightweight-Stream-API,代码行数:14,代码来源:OptionalLong.java

示例10: custom

import com.annimon.stream.function.Function; //导入方法依赖的package包/类
/**
 * Applies custom operator on {@code Optional}.
 *
 * @param <R> the type of the result
 * @param function  a transforming function
 * @return a result of the transforming function
 * @throws NullPointerException if {@code function} is null
 * @since 1.1.9
 */
public <R> R custom(Function<Optional<T>, R> function) {
    Objects.requireNonNull(function);
    return function.apply(this);
}
 
开发者ID:aNNiMON,项目名称:Lightweight-Stream-API,代码行数:14,代码来源:Optional.java


注:本文中的com.annimon.stream.function.Function.apply方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。