formatting work
This commit is contained in:
@@ -9,8 +9,7 @@ public class AttrListener implements ServletContextListener {
|
||||
|
||||
@Override
|
||||
public void contextInitialized(ServletContextEvent servletContextEvent) {
|
||||
servletContextEvent.getServletContext()
|
||||
.setAttribute("servlet-context-attr", "test");
|
||||
servletContextEvent.getServletContext().setAttribute("servlet-context-attr", "test");
|
||||
System.out.println("context init");
|
||||
}
|
||||
|
||||
|
||||
@@ -16,8 +16,7 @@ public class EchoServlet extends HttpServlet {
|
||||
@Override
|
||||
public void doPost(HttpServletRequest request, HttpServletResponse response) {
|
||||
try {
|
||||
Path path = File.createTempFile("echo", "tmp")
|
||||
.toPath();
|
||||
Path path = File.createTempFile("echo", "tmp").toPath();
|
||||
Files.copy(request.getInputStream(), path, StandardCopyOption.REPLACE_EXISTING);
|
||||
Files.copy(path, response.getOutputStream());
|
||||
Files.delete(path);
|
||||
|
||||
@@ -18,8 +18,7 @@ public class HelloFilter implements Filter {
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
|
||||
servletResponse.getOutputStream()
|
||||
.print(filterConfig.getInitParameter("msg"));
|
||||
servletResponse.getOutputStream().print(filterConfig.getInitParameter("msg"));
|
||||
filterChain.doFilter(servletRequest, servletResponse);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,9 +21,7 @@ public class HelloServlet extends HttpServlet {
|
||||
@Override
|
||||
public void doGet(HttpServletRequest request, HttpServletResponse response) {
|
||||
try {
|
||||
response.getOutputStream()
|
||||
.write(servletConfig.getInitParameter("msg")
|
||||
.getBytes());
|
||||
response.getOutputStream().write(servletConfig.getInitParameter("msg").getBytes());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -98,13 +98,8 @@ public class MySQLAutoconfiguration {
|
||||
public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) {
|
||||
ConditionMessage.Builder message = ConditionMessage.forCondition("Hibernate");
|
||||
|
||||
return Arrays.stream(CLASS_NAMES)
|
||||
.filter(className -> ClassUtils.isPresent(className, context.getClassLoader()))
|
||||
.map(className -> ConditionOutcome.match(message.found("class")
|
||||
.items(Style.NORMAL, className)))
|
||||
.findAny()
|
||||
.orElseGet(() -> ConditionOutcome.noMatch(message.didNotFind("class", "classes")
|
||||
.items(Style.NORMAL, Arrays.asList(CLASS_NAMES))));
|
||||
return Arrays.stream(CLASS_NAMES).filter(className -> ClassUtils.isPresent(className, context.getClassLoader())).map(className -> ConditionOutcome.match(message.found("class").items(Style.NORMAL, className))).findAny()
|
||||
.orElseGet(() -> ConditionOutcome.noMatch(message.didNotFind("class", "classes").items(Style.NORMAL, Arrays.asList(CLASS_NAMES))));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -28,9 +28,7 @@ public class ContactInfoValidator implements ConstraintValidator<ContactInfo, St
|
||||
if (StringUtils.isEmptyOrWhitespace(expressionType)) {
|
||||
LOG.error("Contact info type missing!");
|
||||
} else {
|
||||
pattern = expressionRepository.findOne(expressionType)
|
||||
.map(ContactInfoExpression::getPattern)
|
||||
.orElse("");
|
||||
pattern = expressionRepository.findOne(expressionType).map(ContactInfoExpression::getPattern).orElse("");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,10 +18,7 @@ public class PersistenceConfig {
|
||||
@Bean
|
||||
public DataSource dataSource() {
|
||||
EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
|
||||
EmbeddedDatabase db = builder.setType(EmbeddedDatabaseType.H2)
|
||||
.addScript("schema-expressions.sql")
|
||||
.addScript("data-expressions.sql")
|
||||
.build();
|
||||
EmbeddedDatabase db = builder.setType(EmbeddedDatabaseType.H2).addScript("schema-expressions.sql").addScript("data-expressions.sql").build();
|
||||
return db;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,15 +12,11 @@ public class MyBeanNotOfRequiredTypeFailureAnalyzer extends AbstractFailureAnaly
|
||||
}
|
||||
|
||||
private String getDescription(BeanNotOfRequiredTypeException ex) {
|
||||
return String.format("The bean %s could not be injected as %s because it is of type %s", ex.getBeanName(), ex.getRequiredType()
|
||||
.getName(),
|
||||
ex.getActualType()
|
||||
.getName());
|
||||
return String.format("The bean %s could not be injected as %s because it is of type %s", ex.getBeanName(), ex.getRequiredType().getName(), ex.getActualType().getName());
|
||||
}
|
||||
|
||||
private String getAction(BeanNotOfRequiredTypeException ex) {
|
||||
return String.format("Consider creating a bean with name %s of type %s", ex.getBeanName(), ex.getRequiredType()
|
||||
.getName());
|
||||
return String.format("Consider creating a bean with name %s of type %s", ex.getBeanName(), ex.getRequiredType().getName());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,8 +11,6 @@ public class AuthorDao {
|
||||
}
|
||||
|
||||
public Optional<Author> getAuthor(String id) {
|
||||
return authors.stream()
|
||||
.filter(author -> id.equals(author.getId()))
|
||||
.findFirst();
|
||||
return authors.stream().filter(author -> id.equals(author.getId())).findFirst();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,8 +13,7 @@ public class Mutation implements GraphQLMutationResolver {
|
||||
|
||||
public Post writePost(String title, String text, String category, String author) {
|
||||
Post post = new Post();
|
||||
post.setId(UUID.randomUUID()
|
||||
.toString());
|
||||
post.setId(UUID.randomUUID().toString());
|
||||
post.setTitle(title);
|
||||
post.setText(text);
|
||||
post.setCategory(category);
|
||||
|
||||
@@ -11,16 +11,11 @@ public class PostDao {
|
||||
}
|
||||
|
||||
public List<Post> getRecentPosts(int count, int offset) {
|
||||
return posts.stream()
|
||||
.skip(offset)
|
||||
.limit(count)
|
||||
.collect(Collectors.toList());
|
||||
return posts.stream().skip(offset).limit(count).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public List<Post> getAuthorPosts(String author) {
|
||||
return posts.stream()
|
||||
.filter(post -> author.equals(post.getAuthorId()))
|
||||
.collect(Collectors.toList());
|
||||
return posts.stream().filter(post -> author.equals(post.getAuthorId())).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public void savePost(Post post) {
|
||||
|
||||
@@ -31,6 +31,6 @@ public class MvcConfig extends WebMvcConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
registry.addInterceptor(localeChangeInterceptor());
|
||||
registry.addInterceptor(localeChangeInterceptor());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,18 +15,17 @@ public class QueryController {
|
||||
private static int REQUEST_COUNTER = 0;
|
||||
|
||||
@GetMapping("/reqcount")
|
||||
public int getReqCount(){
|
||||
public int getReqCount() {
|
||||
return REQUEST_COUNTER;
|
||||
}
|
||||
|
||||
@GetMapping("/{code}")
|
||||
public String getStockPrice(@PathVariable String code){
|
||||
public String getStockPrice(@PathVariable String code) {
|
||||
REQUEST_COUNTER++;
|
||||
if("BTC".equalsIgnoreCase(code))
|
||||
if ("BTC".equalsIgnoreCase(code))
|
||||
return "10000";
|
||||
else return "N/A";
|
||||
else
|
||||
return "N/A";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -28,11 +28,7 @@ public class WebMvcConfigure extends WebMvcConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
registry.addResourceHandler("/resources/**")
|
||||
.addResourceLocations("/resources/")
|
||||
.setCachePeriod(3600)
|
||||
.resourceChain(true)
|
||||
.addResolver(new PathResourceResolver());
|
||||
registry.addResourceHandler("/resources/**").addResourceLocations("/resources/").setCachePeriod(3600).resourceChain(true).addResolver(new PathResourceResolver());
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -13,7 +13,6 @@ public class AnnotationServlet extends HttpServlet {
|
||||
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
request.getRequestDispatcher("/annotationservlet.jsp")
|
||||
.forward(request, response);
|
||||
request.getRequestDispatcher("/annotationservlet.jsp").forward(request, response);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,12 +14,10 @@ public class FeaturesAspect {
|
||||
|
||||
@Around(value = "@within(featureAssociation) || @annotation(featureAssociation)")
|
||||
public Object checkAspect(ProceedingJoinPoint joinPoint, FeatureAssociation featureAssociation) throws Throwable {
|
||||
if (featureAssociation.value()
|
||||
.isActive()) {
|
||||
if (featureAssociation.value().isActive()) {
|
||||
return joinPoint.proceed();
|
||||
} else {
|
||||
LOG.info("Feature " + featureAssociation.value()
|
||||
.name() + " is not enabled!");
|
||||
LOG.info("Feature " + featureAssociation.value().name() + " is not enabled!");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,8 +17,7 @@ public enum MyFeatures implements Feature {
|
||||
EMPLOYEE_MANAGEMENT_FEATURE;
|
||||
|
||||
public boolean isActive() {
|
||||
return FeatureContext.getFeatureManager()
|
||||
.isActive(this);
|
||||
return FeatureContext.getFeatureManager().isActive(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user