« first day (3784 days earlier)      last day (1140 days later) » 

12:00 AM
1 Mole = 007 Secret Agents (source)
 
 
3 hours later…
3:20 AM
twiddles thumbs
 
 
6 hours later…
9:20 AM
uses java.io.File
 
10:12 AM
o.o
 
Zoe
I know
Now we have to whip oak with electric whips
 
pfft like it would feel that
oil yerr whips
burn it
then clack oak!
 
Zoe
You're forgetting that electric whips will short his circuits :blobthinksmart:
@Michael didn't make the compooper electric whip-resistant :p
 
hmm I am merely here about jackson json lib
create a single instance for all code or construct it each time?
 
Zoe
as long as it works, it shouldn't make a difference. Use whatever is the most convenient for your code
 
10:16 AM
convenience <-> consistency
that's why I am ... reflecting that. Questioning it
(and pfft, oak is a trunk for me. he can communicate by coincidence. Like Meowth)
 
Zoe
I mean, you could just make a singleton and call it a day. Still does the trick
^^
 
 
2 hours later…
12:36 PM
@KarelG convenience + consistency
I have several ObjectMappers
but reuse them as much as possible
they are separated by responsibility
 
I have decided to have this: default constructs -> use the util class
with custom readers? make one yourself
 
for example, parsing SO-chat messages (json) would be its own ObjectMapper
and parsing results from AWS Lambda (json) would be its own ObjectMapper
but every request would reuse the existing one
this often means that the library can package with a fully configured ObjectMapper
but I still leave the option to override it
 
how do you "override" it?
passing a different objectmapper instance to it when application starts?
 
the constructor of the service optionally accepts an ObjectMapper to be used
if none is specified, it creates the one as configured by the library
 
1:35 PM
Dang it @Zoe!! Stop whipping Oak!!
 
@Michael I don't mind she's whipping Oak. It might be sexy ... or ugly 😎
or both 😁
 
Zoe
^^"
@Michael Dang it @Mic!! Never!! :P
 
2:11 PM
posted on March 03, 2021

archive - contact - sexy exciting merchandise - search - about ← previousMarch 3rd, 2021nextMarch 3rd, 2021: Hey, someone emailed me saying "it's been a year, we know about your mailing list, tell us something ELSE down here" and you know what? FAIR POINT. So here's something else: I had a good roast chicken for dinner yesterday! And even more interesting than THAT is the news that Powe

 
2:32 PM
Dang it @KarelG!! Stop enjoying it!!
 
2:53 PM
Mikeeeeeeeeeeeeeeeeeeeeee
 
 
1 hour later…
3:57 PM
hi all , I am a dotnet developer and trying to migrate a piece of dotnet code to java. Can anyone help me for the below piece of code:

bool hasAccess = false;
Dictionary<string, string> rolesOnSecurityActions
List<string> securityRoles
hasAccess = securityRoles.Any(x => rolesOnSecurityActions.Keys.Any(y => y == x));
 
bool -> boolean
string -> String
dictionary -> Map (HashMap)
.Any -> .stream().anyMatch(...)
 
@KarelG rolesOnSecurityActions.Any is not there
 
I just gave the Java variant?
imagine this
# in .NET
List<string> securityRoles = ...
hasAccess = securityRoles.Any( ... )

# is just this in Java
List<String> securityRoles = ...
hasAccess = securityRoles.stream().anyMatch( ... )
you need to check the api docs to get familiar with that
 
okay, i have tried this, but not getting how to pass each String variable of the list
@KarelG: i think this would serve the purpose: hasAccess = securityRoles.stream().allMatch(x -> rolesOnSecurityActions.containsKey(x));
 
 
6 hours later…
10:18 PM
hums a song
 
public void foo(Map<String, String> rolesOnSecurityActions, List<String> securityRoles)
{
	boolean hasAccess1 = securityRoles
		.stream()
		.anyMatch(key -> rolesOnSecurityActions.keySet().stream().anyMatch(it -> it.equals(key)));

	boolean hasAccess2 = securityRoles
		.stream()
		.anyMatch(key -> rolesOnSecurityActions.containsKey(key));

	boolean hasAccess3 = securityRoles
		.stream()
		.anyMatch(rolesOnSecurityActions::containsKey);
}
@SoumyashreePattnaik the first one is a direct translation
however, both Java and C# would benefit from using Map.containsKey and IDictionary.ContainsKey respectively
which is the second version
the third makes use of a neat feature which you can use when you have a lambda that simply passes the argument to a function
C# also has this "method reference" but in C#, it only works like 10% of the time
I doubt it would work in this case because it cant resolve it from a variable
but I am not entirely sure of that
in any case, you still want anyMatch, not allMatch
considering that the C# code was working correctly
 

« first day (3784 days earlier)      last day (1140 days later) »