Ron McLeod

+ Follow
since Feb 12, 2013
Ron likes ...
VSCode Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
Merit badge: grant badges
For More
Richmond, BC, Canada
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt Green check
expand Greenhorn Scavenger Hunt

Recent posts by Ron McLeod

Anil Philip wrote:This question is different from the thread you referenced because here we are considering different classes - not different instances of the same class (which is what the other thread discussed).

Yes - the question is a bit different, but the answer is the same (if I correctly understand what you are asking).

From Controlling Access to Members of a Class:

The Oracle tutorial wrote:The protected modifier specifies that the member can only be accessed within its own package (as with package-private) and, in addition, by a subclass of its class in another package.

15 hours ago
If you mean inside an operation, then no.
1 week ago
You should be able to peek into a Map and Map.Entry.  I'm running Java 21; maybe it is different in other versions.

1 week ago
Thanks for the example - it helped me realize that accept could be called more than once - that lets me avoid needing to collect downstream elements in a temporary collection when using flatMap.

For example - I have an annotation which defines what types of content a class can process:
In order to work-around some issues using Graalvm to create a native executable, I need to extract and transform to the information in annotations at Graalvm's build time.  For each annotation in, there could be multiple elements out.  In the example below, I collected the elements to a List, returned it as a stream, and then flattened it using flatMap:
Using mapMulti, I can eliminate the List:
1 week ago
Java 16 added Stream#mapMulti.

It seems like one advantage of using this method over flatMap or a combination of filter and map is the reduction in the number of streams created; which probably translates into better performance.  Are there any other benefits?
1 week ago
This article looks like it might provide the answers you are looking for: HowToDoInJava: Spring Boot Log4j2.xml.  The config file looks quite similar to what I just posted.
1 week ago
I've never worked with Spring or SpringBoot, but here's what I did for the last project which used log4j2 logging with file rotation:
I'm not sure how that would translate in to SpringBoot configuration, but maybe it can provide some clues.
1 week ago

Lou Hamers wrote:I thought I agreed at first, but actually I don't think that produces an NPE (if the error really is a NullPointerException). That'd be a NumberFormatException right?

You're right, a blank or non-number value would throw a NumberFormatException, but if a reference to null was provided, it would result in a NullPointerException.  

This could easily happen with browser did not provide the expected value, or it was looked-up improperly in the Servlet (request.getParameter("loanamount") instead of request.getParameter("loanAmount")).
1 week ago
It seems like you must be providing some non-numeric data.
1 week ago

Lou Hamers wrote:You should post a more complete example ...

Agreed - in particular, what does your test data look like.
1 week ago

Sam Muller wrote:

LinkedList#offerFirst is only applicable for instances of LinkedList (it is not inherited from List).  In your code, l1 is declared as an instance of List, not LinkedList.
2 weeks ago

Paul Houle wrote:What do you call something that calls a Consumer?

Generically I would just call something that calls a Consumer,  a Consumer-invoker, but a more specific name would depend on the particular usage in the code.
2 weeks ago