本文整理了Java中org.nutz.lang.Lang.list()
方法的一些代码示例,展示了Lang.list()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Lang.list()
方法的具体详情如下:
包路径:org.nutz.lang.Lang
类名称:Lang
方法名:list
[英]较方便的创建一个列表,比如:
List<Pet> pets = Lang.list(pet1, pet2, pet3);
注,这里的 List,是 ArrayList 的实例
[中]较方便的创建一个列表,比如:
List<Pet> pets = Lang.list(pet1, pet2, pet3);
注,这里的 列表是 ArrayList的实例
代码示例来源:origin: nutzam/nutz
public List<MappingField> getPks() {
if (null != theId)
return Lang.list(theId);
if (null != theName)
return Lang.list(theName);
return theComposites;
}
代码示例来源:origin: nutzam/nutz
public Pojo insertFirst(PItem... itemAry) {
items.addAll(0, Lang.list(itemAry));
for (PItem pi : itemAry)
pi.setPojo(this);
return this;
}
代码示例来源:origin: nutzam/nutz
/**
* 解析MAP配置信息
* @param obj
* @param path
*/
private void loadMapRelation(Map<?, ?> obj, String path) {
for(Object key : obj.keySet()){
Object val = obj.get(key);
if(val instanceof String){
relation.put(path + space(path) + key.toString(), Lang.list(val.toString()));
continue;
}
loadRelation(obj.get(key), path + space(path) + key.toString());
}
}
代码示例来源:origin: nutzam/nutz
public DaoSupport() {
this.runner = new NutDaoRunner();
this.executor = new NutDaoExecutor();
this.setInterceptors(Lang.list((Object)"log"));
}
代码示例来源:origin: nutzam/nutz
@Override
@SuppressWarnings("unchecked")
public <T> List<T> getList(String key, final Class<T> eleType, List<T> dft) {
Object v = get(key);
if (null == v)
return dft;
if (v instanceof CharSequence) {
return Lang.list(Castors.me().castTo(v, eleType));
}
int len = Lang.eleSize(v);
final List<T> list = new ArrayList<T>(len);
Lang.each(v, new Each<Object>() {
@Override
public void invoke(int index, Object ele, int length) {
list.add(Castors.me().castTo(ele, eleType));
}
});
return list;
}
代码示例来源:origin: org.nutz/nutz
public List<MappingField> getPks() {
if (null != theId)
return Lang.list(theId);
if (null != theName)
return Lang.list(theName);
return theComposites;
}
代码示例来源:origin: org.nutz/nutz
public Pojo insertFirst(PItem... itemAry) {
items.addAll(0, Lang.list(itemAry));
for (PItem pi : itemAry)
pi.setPojo(this);
return this;
}
代码示例来源:origin: zzycreate/spring-boot-seed
/**
* 获取多个值
*
* @param keys key集合
* @return result
*/
public Map<String, String> get(String... keys) {
return this.get(Lang.list(keys));
}
代码示例来源:origin: org.nutz/nutz
/**
* 解析MAP配置信息
* @param obj
* @param path
*/
private void loadMapRelation(Map<?, ?> obj, String path) {
for(Object key : obj.keySet()){
Object val = obj.get(key);
if(val instanceof String){
relation.put(path + space(path) + key.toString(), Lang.list(val.toString()));
continue;
}
loadRelation(obj.get(key), path + space(path) + key.toString());
}
}
代码示例来源:origin: zzycreate/spring-boot-seed
/**
* 将来源按转换器的方式转换成Map<Key,List<Obj>>的方式.
*
* @param sources 来源
* @param convertor 转换器
* @param <Key> 返回的Map的key的类型
* @param <Obj> 返回的Map的value的List包含类型
* @return 转换后的对象类型
*/
public static <Key, Obj> Map<Key, List<Obj>> maplist(Collection<Obj> sources, IConvertor<Obj, Key> convertor) {
Map<Key, List<Obj>> mapping = new HashMap<>(16);
// 来源不为空
if (sources != null && sources.size() > 0) {
for (Obj obj : sources) {
Key key = convertor.convert(obj);
List<Obj> list = mapping.get(key);
if (list == null) {
mapping.put(key, Lang.list(obj));
} else {
list.add(obj);
}
}
}
return mapping;
}
代码示例来源:origin: club.zhcs/axe-swagger
/**
* 局部参数按照name覆盖局部参数
*
* @param globalOperationParameters
* @param docketOperationParameters
* @return
*/
private List<Parameter> assemblyGlobalOperationParameters(
List<SwaggerConfigurationProerties.GlobalOperationParameter> globalOperationParameters,
List<SwaggerConfigurationProerties.GlobalOperationParameter> docketOperationParameters) {
if (Objects.isNull(docketOperationParameters) || docketOperationParameters.isEmpty()) {
return buildGlobalOperationParametersFromSwaggerConfigurationProerties(globalOperationParameters);
}
Set<String> docketNames = docketOperationParameters.stream()
.map(SwaggerConfigurationProerties.GlobalOperationParameter::getName)
.collect(Collectors.toSet());
List<SwaggerConfigurationProerties.GlobalOperationParameter> resultOperationParameters = Lang.list();
if (Objects.nonNull(globalOperationParameters)) {
for (SwaggerConfigurationProerties.GlobalOperationParameter parameter : globalOperationParameters) {
if (!docketNames.contains(parameter.getName())) {
resultOperationParameters.add(parameter);
}
}
}
resultOperationParameters.addAll(docketOperationParameters);
return buildGlobalOperationParametersFromSwaggerConfigurationProerties(resultOperationParameters);
}
代码示例来源:origin: org.nutz/nutz
public DaoSupport() {
this.runner = new NutDaoRunner();
this.executor = new NutDaoExecutor();
this.setInterceptors(Lang.list((Object)"log"));
}
代码示例来源:origin: club.zhcs/axe-validation
@ResponseBody
@ExceptionHandler(MethodArgumentNotValidException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
public Result handle(MethodArgumentNotValidException exception) {
final List<NutMap> errors = new ArrayList<NutMap>();
final List<String> infos = Lang.list();
Lang.each(exception.getBindingResult().getAllErrors(), new Each<ObjectError>() {
@Override
public void invoke(int index, ObjectError error, int length) throws ExitLoop, ContinueLoop, LoopException {
infos.add(error.getDefaultMessage());
errors.add(NutMap.NEW()
.addv("msg", error.getDefaultMessage())
.addv("obj", error.getObjectName())
.addv("arguments", error.getArguments())
.addv("code",
error.getCode())
.addv("codes", error.getCodes()));
}
});
return Result.fail(infos).addData("details", errors);
}
代码示例来源:origin: club.zhcs/axe-validation
@ResponseBody
@ExceptionHandler(ValidationException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
public Result handle(ValidationException exception) {
if (exception instanceof ConstraintViolationException) {
final List<NutMap> errors = new ArrayList<NutMap>();
final List<String> infos = Lang.list();
Lang.each(((ConstraintViolationException) exception).getConstraintViolations(), new Each<ConstraintViolation>() {
@Override
public void invoke(int index, ConstraintViolation error, int length) throws ExitLoop, ContinueLoop, LoopException {
infos.add(error.getMessage());
errors.add(NutMap.NEW().addv("msg", error.getMessage()).addv("obj", error.getConstraintDescriptor()).addv("arguments", error.getExecutableParameters()));
}
});
return Result.fail(infos).addData("details", errors);
}
return Result.fail("参数不正确");
}
}
代码示例来源:origin: org.nutz/nutz
@Override
@SuppressWarnings("unchecked")
public <T> List<T> getList(String key, final Class<T> eleType, List<T> dft) {
Object v = get(key);
if (null == v)
return dft;
if (v instanceof CharSequence) {
return Lang.list(Castors.me().castTo(v, eleType));
}
int len = Lang.eleSize(v);
final List<T> list = new ArrayList<T>(len);
Lang.each(v, new Each<Object>() {
@Override
public void invoke(int index, Object ele, int length) {
list.add(Castors.me().castTo(ele, eleType));
}
});
return list;
}
代码示例来源:origin: Rekoe/rk_svnadmin
public void addRole(Long userId, Long roleId) {
User user = fetch(userId);
Role role = new Role();
role.setId(roleId);
user.setRoles(Lang.list(role));
dao().insertRelation(user, "roles");
}
代码示例来源:origin: club.zhcs/axe-swagger
private List<Parameter> buildGlobalOperationParametersFromSwaggerConfigurationProerties(
List<SwaggerConfigurationProerties.GlobalOperationParameter> globalOperationParameters) {
List<Parameter> parameters = Lang.list();
if (Objects.isNull(globalOperationParameters)) {
return parameters;
}
for (SwaggerConfigurationProerties.GlobalOperationParameter globalOperationParameter : globalOperationParameters) {
parameters.add(new ParameterBuilder()
.name(globalOperationParameter.getName())
.description(globalOperationParameter.getDescription())
.modelRef(new ModelRef(globalOperationParameter.getModelRef()))
.parameterType(globalOperationParameter.getParameterType())
.required(Boolean.parseBoolean(globalOperationParameter.getRequired()))
.build());
}
return parameters;
}
代码示例来源:origin: club.zhcs/axe-swagger
/**
* 获取返回消息体列表
*
* @param globalResponseMessageBodyList
* 全局Code消息返回集合
* @return
*/
private List<ResponseMessage> getResponseMessageList(List<SwaggerConfigurationProerties.GlobalResponseMessageBody> globalResponseMessageBodyList) {
List<ResponseMessage> responseMessages = Lang.list();
for (SwaggerConfigurationProerties.GlobalResponseMessageBody globalResponseMessageBody : globalResponseMessageBodyList) {
ResponseMessageBuilder responseMessageBuilder = new ResponseMessageBuilder();
responseMessageBuilder.code(globalResponseMessageBody.getCode()).message(globalResponseMessageBody.getMessage());
if (!StringUtils.isEmpty(globalResponseMessageBody.getModelRef())) {
responseMessageBuilder.responseModel(new ModelRef(globalResponseMessageBody.getModelRef()));
}
responseMessages.add(responseMessageBuilder.build());
}
return responseMessages;
}
}
内容来源于网络,如有侵权,请联系作者删除!