本文整理汇总了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;
}
示例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();
}
示例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();
}
}