本文整理汇总了Java中org.springframework.lang.UsesJava8类的典型用法代码示例。如果您正苦于以下问题:Java UsesJava8类的具体用法?Java UsesJava8怎么用?Java UsesJava8使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UsesJava8类属于org.springframework.lang包,在下文中一共展示了UsesJava8类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: setCreationTimeIfPossible
import org.springframework.lang.UsesJava8; //导入依赖的package包/类
@UsesJava8
private void setCreationTimeIfPossible(JarEntry source, JarEntry target) {
try {
if (source.getCreationTime() != null) {
target.setCreationTime(source.getCreationTime());
}
}
catch (NoSuchMethodError ex) {
// Not running on Java 8. Continue.
}
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:12,代码来源:Repackager.java
示例2: setLastAccessTimeIfPossible
import org.springframework.lang.UsesJava8; //导入依赖的package包/类
@UsesJava8
private void setLastAccessTimeIfPossible(JarEntry source, JarEntry target) {
try {
if (source.getLastAccessTime() != null) {
target.setLastAccessTime(source.getLastAccessTime());
}
}
catch (NoSuchMethodError ex) {
// Not running on Java 8. Continue.
}
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:12,代码来源:Repackager.java
示例3: setLastModifiedTimeIfPossible
import org.springframework.lang.UsesJava8; //导入依赖的package包/类
@UsesJava8
private void setLastModifiedTimeIfPossible(JarEntry source, JarEntry target) {
try {
if (source.getLastModifiedTime() != null) {
target.setLastModifiedTime(source.getLastModifiedTime());
}
}
catch (NoSuchMethodError ex) {
// Not running on Java 8. Continue.
}
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:12,代码来源:Repackager.java
示例4: resolveArgument
import org.springframework.lang.UsesJava8; //导入依赖的package包/类
@Override
@UsesJava8
public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer,
NativeWebRequest request, WebDataBinderFactory binderFactory) throws Exception {
HttpServletRequest servletRequest = request.getNativeRequest(HttpServletRequest.class);
assertIsMultipartRequest(servletRequest);
MultipartHttpServletRequest multipartRequest =
WebUtils.getNativeRequest(servletRequest, MultipartHttpServletRequest.class);
Class<?> paramType = parameter.getParameterType();
boolean optional = paramType.getName().equals("java.util.Optional");
if (optional) {
parameter.increaseNestingLevel();
paramType = parameter.getNestedParameterType();
}
String partName = getPartName(parameter);
Object arg;
if (MultipartFile.class == paramType) {
Assert.notNull(multipartRequest, "Expected MultipartHttpServletRequest: is a MultipartResolver configured?");
arg = multipartRequest.getFile(partName);
}
else if (isMultipartFileCollection(parameter)) {
Assert.notNull(multipartRequest, "Expected MultipartHttpServletRequest: is a MultipartResolver configured?");
arg = multipartRequest.getFiles(partName);
}
else if (isMultipartFileArray(parameter)) {
Assert.notNull(multipartRequest, "Expected MultipartHttpServletRequest: is a MultipartResolver configured?");
List<MultipartFile> files = multipartRequest.getFiles(partName);
arg = files.toArray(new MultipartFile[files.size()]);
}
else if ("javax.servlet.http.Part".equals(paramType.getName())) {
assertIsMultipartRequest(servletRequest);
arg = servletRequest.getPart(partName);
}
else if (isPartCollection(parameter)) {
assertIsMultipartRequest(servletRequest);
arg = new ArrayList<Object>(servletRequest.getParts());
}
else if (isPartArray(parameter)) {
assertIsMultipartRequest(servletRequest);
arg = RequestPartResolver.resolvePart(servletRequest);
}
else {
try {
HttpInputMessage inputMessage = new RequestPartServletServerHttpRequest(servletRequest, partName);
arg = readWithMessageConverters(inputMessage, parameter, parameter.getNestedGenericParameterType());
WebDataBinder binder = binderFactory.createBinder(request, arg, partName);
if (arg != null) {
validateIfApplicable(binder, parameter);
if (binder.getBindingResult().hasErrors() && isBindExceptionRequired(binder, parameter)) {
throw new MethodArgumentNotValidException(parameter, binder.getBindingResult());
}
}
mavContainer.addAttribute(BindingResult.MODEL_KEY_PREFIX + partName, binder.getBindingResult());
}
catch (MissingServletRequestPartException ex) {
// handled below
arg = null;
}
}
RequestPart requestPart = parameter.getParameterAnnotation(RequestPart.class);
boolean isRequired = ((requestPart == null || requestPart.required()) && !optional);
if (arg == null && isRequired) {
throw new MissingServletRequestPartException(partName);
}
if (optional) {
arg = Optional.ofNullable(arg);
}
return arg;
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:78,代码来源:RequestPartMethodArgumentResolver.java
注:本文中的org.springframework.lang.UsesJava8类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论