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


Java List.size方法代码示例

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


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

示例1: createAccount

import javaslang.collection.List; //导入方法依赖的package包/类
@Override
public Account createAccount(String name, String password) throws Exception {

    List<Account> existing = accounts.filter(a -> a.getAccountName().equals(name)).toList();

    if (existing.size() > 0) {
        throw new Exception("account already exists");
    }

    Account acc = new Account();
    acc.setAccountName(name);
    acc.setAccountPassword(password);
    acc.setAcountId(UUID.randomUUID().toString());
    accounts = accounts.append(acc);
    return acc;
}
 
开发者ID:drinkwater-io,项目名称:drinkwater-java,代码行数:17,代码来源:AccountService.java

示例2: login

import javaslang.collection.List; //导入方法依赖的package包/类
@Override
public Account login(String name, String password) throws Exception {
    List<Account> acclist = accounts.filter(a -> a.getAccountName().equals(name))
            .filter(a -> a.getAccountPassword().equals(password)).toList();

    if (acclist.size() == 0) {
        throw new Exception("login failed");
    }

    acclist.get().setAuthenticated(true);

    return acclist.get();
}
 
开发者ID:drinkwater-io,项目名称:drinkwater-java,代码行数:14,代码来源:AccountService.java

示例3: init

import javaslang.collection.List; //导入方法依赖的package包/类
private void init() {
    HttpMethod httpMethod = httpMethodFor(method);
    List<Parameter> parameterInfos = javaslang.collection.List.of(method.getParameters());
    NoBody noBodyAnnotation = method.getAnnotation(NoBody.class);

    hasReturn = returnsVoid(method);

    if (parameterInfos.size() == 0) {
        return;
    }

    if (httpMethod == HttpMethod.GET) {
        hasBody = false;
    } else if (httpMethod == HttpMethod.POST || httpMethod == HttpMethod.DELETE || httpMethod == HttpMethod.PUT) {
        if (parameterInfos.size() > 0) {
            hasBody = true;
        }
        if (noBodyAnnotation != null) {
            hasBody = false;
        }
    } else {
        throw new RuntimeException("come back here : MethodToRestParameters.init()");
    }

    if (hasBody) { // first parameter of the method will be assigned with the body content
        headerNames = parameterInfos.tail().map(p -> mapName(p)).toList();
    } else {

        headerNames = parameterInfos.map(p -> mapName(p)).toList();
    }

}
 
开发者ID:drinkwater-io,项目名称:drinkwater-java,代码行数:33,代码来源:MethodToRestParameters.java


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