java-8

POSTMAN is returning date fields with changed values

為{幸葍}努か 提交于 2021-01-28 04:21:01
问题 I am consuming a REST service and I am receiving a JSON with date attributes that do not match what is in my database. I have two fields called "initialDate" and "finalDate". In the database they are like this: 07/MAR/19 00:00:00 07/SEP/19 23:59:59 The database timezone: select dbtimezone from dual; +00:00 In my object, inside the Java class, the content of the attributes comes as: public class Klass { @NotNull private Date initialDate; //initialDate.toString() "Thu Mar 07 00:00:00 CLT 2019"

How to have a click on component in a grid cell in Vaadin 8 Grid to select cells row?

隐身守侯 提交于 2021-01-28 03:49:22
问题 When clicking a cell in a Vaadin 8 Grid that contains component like VerticalLayout row does not get selected (using Vaadin 8.1.5). If the component does not fill the whole cell then clicking the unused area in cell makes the row selected. I have been researching how could the click on component be forwarded to the cell click listener but have not get any grip yet on that. Guess it is even not the best way to do it. What would be the solution? 回答1: I provide my own current solution as an

Effectively final - Inner classes access

元气小坏坏 提交于 2021-01-27 20:45:08
问题 Inner classes only have access to final or effectively final variables. I don't understand though, why an instance variable can be accessed no matter what, but local variables and method parameters need to be at minimum effectively final? Consider the following code: public class BookStore { private static final int taxId = 300000; public String name; public String searchBook(final String criteria) { int count = 0; int sum = 0; // name = ""; I can uncomment this -> no compile error class

Returning from Java Optional ifPresent()

烂漫一生 提交于 2021-01-27 14:15:27
问题 I understand you can't return from a ifPresent() so this example does not work: public boolean checkSomethingIfPresent() { mightReturnAString().ifPresent((item) -> { if (item.equals("something")) { // Do some other stuff like use "something" in API calls return true; // Does not compile } }); return false; } Where mightReturnAString() could return a valid string or an empty optional. What I have done that works is: public boolean checkSomethingIsPresent() { Optional<String> result =

Java 8 nested null check for a string in a map in a list

℡╲_俬逩灬. 提交于 2021-01-27 11:50:47
问题 I need to do a series of null checks ( nested null-checks ) to get an array of strings like below String[] test; if(CollectionUtils.isNotEmpty(checkList)){ if(MapUtils.isNotEmpty(checkList.get(0))){ if(StringUtils.isNotBlank(checkList.get(0).get("filename"))){ test = checkList.get(0).get("filename").split("_"); } } } Is there a better way, maybe using Java8 Optional, to perform these kind of nested checks? I unsuccessfully tried to use Optional with flatmap / map. 回答1: You could use a long

Java 8 nested null check for a string in a map in a list

谁说胖子不能爱 提交于 2021-01-27 11:46:27
问题 I need to do a series of null checks ( nested null-checks ) to get an array of strings like below String[] test; if(CollectionUtils.isNotEmpty(checkList)){ if(MapUtils.isNotEmpty(checkList.get(0))){ if(StringUtils.isNotBlank(checkList.get(0).get("filename"))){ test = checkList.get(0).get("filename").split("_"); } } } Is there a better way, maybe using Java8 Optional, to perform these kind of nested checks? I unsuccessfully tried to use Optional with flatmap / map. 回答1: You could use a long

How to filter a specific exception from Log4j?

你离开我真会死。 提交于 2021-01-27 06:19:56
问题 I'm implementing some new features of Java 8 on my desktop app and Hibernate 3.6 seems to doesn't like it. I added to an Interface a "default method", since then Hibernate it throwing: 2014-10-02 14:01:25,538 WARN entity.PojoEntityTuplizer - could not create proxy factory for:modelo.ChequeTercero org.hibernate.HibernateException: Javassist Enhancement failed: modelo.ChequeTercero at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.getProxyFactory(JavassistLazyInitializer.java:169)

Java 8 stream to collect a Map of List of items

非 Y 不嫁゛ 提交于 2021-01-26 18:15:30
问题 I have a List of Maps which stores the roles and the names of people. For ex: List<Map<String, String>> listOfData 1) Role: Batsman Name: Player1 2)Role: Batsman Name: Player2 3)Role: Bowler Name: Player3 Role and Name are the Keys of the map. I want to convert this into a Map<String, List<String>> result , which will give me a list of names for each role, i.e k1: Batsman v1: [Player1, Player2] k2: Bowler v2: [Player3] listOfData .stream() .map(entry -> new AbstractMap.SimpleEntry<>(entry.get

Java 8 stream to collect a Map of List of items

╄→尐↘猪︶ㄣ 提交于 2021-01-26 18:12:23
问题 I have a List of Maps which stores the roles and the names of people. For ex: List<Map<String, String>> listOfData 1) Role: Batsman Name: Player1 2)Role: Batsman Name: Player2 3)Role: Bowler Name: Player3 Role and Name are the Keys of the map. I want to convert this into a Map<String, List<String>> result , which will give me a list of names for each role, i.e k1: Batsman v1: [Player1, Player2] k2: Bowler v2: [Player3] listOfData .stream() .map(entry -> new AbstractMap.SimpleEntry<>(entry.get

Java 8 stream to collect a Map of List of items

[亡魂溺海] 提交于 2021-01-26 18:10:23
问题 I have a List of Maps which stores the roles and the names of people. For ex: List<Map<String, String>> listOfData 1) Role: Batsman Name: Player1 2)Role: Batsman Name: Player2 3)Role: Bowler Name: Player3 Role and Name are the Keys of the map. I want to convert this into a Map<String, List<String>> result , which will give me a list of names for each role, i.e k1: Batsman v1: [Player1, Player2] k2: Bowler v2: [Player3] listOfData .stream() .map(entry -> new AbstractMap.SimpleEntry<>(entry.get