« first day (2132 days earlier)      last day (2814 days later) » 

1:52 AM
vinnie has been released!
 
2:31 AM
is this a room for java?
 
 
5 hours later…
7:12 AM
morn
 
morn
 
7:43 AM
Morn
 
 
2 hours later…
fge
10:32 AM
OK, submitted the documentation problem of Pattern#asPredicate to Oracle
We will see how they react to it...
 
 
2 hours later…
12:41 PM
Guys, some advice, if you may
I have an object, a serializer for that object, and a decorator for that object.
I have a value on the primary object, that I want hidden from the serializer (or some way to have the serializer to ignore), but visible to the decorator
When I serialize the object, I want the property to be excluded, but when I serialize the decorated object, I want it to be there
They both implement an interface method called getThing()
I want getThin() to return "nothing" for the real object, but this.thing for the decorated object
The object and the decorate implement the same interface, but currently do not have an inheritance hierarchy.
 
fge
Is that some JSON related problem again?
 
@fge Not strictly.
But yes, JSON is involved.
In the primary object, I have a property which is a long string
Which is composed of several properties
And in the decorator, the properties are separate
 
fge
brain temperature rising due to not understanding the core of the problem
Why a decorator here? Why not two different, say, Consumers?
 
@fge What do you mean?
 
fge
Well, I don't understand the context fully but it seems that this phrase from yours, at a first glance, points to a XY problem: "I have a value on the primary object, that I want hidden from the serializer (or some way to have the serializer to ignore), but visible to the decorator"
 
12:50 PM
@fge Okay, I'll try my best to explain.
 
fge
This or something is missing from the context
 
The primary object is serialized using a custom serializer, into a large JS object
(It's not strictly JSON because it has JS functions embedded in it)
 
fge
Indeed it isn't JSON at this point, yes
 
The primary object is composed of 4 main parts: The "mode" properties, which is in the form of {"mode1":{"prop1":"value1",...},"mode2":{...},...}
The "global" properties, which is a simple key:value object
The "other" properties, which are another key:value object
And the "style", which is a large string of CSS, which the serializer composes of the different properties on the object
So far so good?
Now, I'm creating a new kind of such JSON object, a filtered version. This basically means that the "mode" properties ("prop1", "prop2") go through a whitelist first, and are excluded from the JS object result if they aren't on the list, in addition to that, the "style" gets separated into several strings, instead of one monolithic one
This method on the serializer describes how I build the big "style" property:
private String concatStyles(LoaderConfig config) {
  String styles = config.getModes().values().stream()
    .map(LoaderMode::getStyle)
    .filter(style -> style != null)
    .collect(Collectors.joining());

  String customCss = config.getModes().values().stream()
    .map(LoaderMode::getCustomCss)
    .filter(style -> style != null)
    .collect(Collectors.joining());

  return config.getRtlcss() + styles + config.getCustomCss() + customCss;
}
So I have two primary options, both equally valid.
Either make the Serializer polymorphic, can use a different Serializer for the different versions of the JS object I want
Or use a different "view" of the LoaderConfig object, which is what I went with
(It's still early enough to change, if I wanted to)
I wanted to go with the "different serializer" way first, but couldn't find a clean way to do it
 
mornin fellers and yellers
 
1:00 PM
@ballBreaker hOi
 
nice to see y'all!
 
fge
@MadaraUchiha make the Serializer constructor parameterized maybe?
 
@fge I'm not the one constructing the Serializer. Jackson does that.
 
god damn it, now I miss that game
 
fge
1:03 PM
Uhm
 
oh my god the frequency at the beginnign destroyed me
 
fge
You can use Jackson to use a custom serializer at runtime
 
@fge As in, pass it an already made instance, instead of SomeSerializer.class?
How?
 
@MadaraUchiha lmao what in the heck is this
 
1:04 PM
I've been looking for that option for the better part of a day, and couldn't find it.
@ballBreaker Undertale. Go play it if you haven't yet.
Don't watch/read/search anything about it. Just do.
 
It looks hilarious
 
@ballBreaker It's amazing
 
heyo all
 
fge
Of course the example on this web page is oversimplified for your case, but I believe you can adapt it for your needs
 
1:05 PM
@ballBreaker hey balls
 
@MadaraUchiha this video makes me so uncomfortable
 
@fge What's a Module to Jackson?
 
@ColdFire ay dude
 
@MadaraUchiha module is kind of library project
 
fge
@MadaraUchiha a way to serialize, or deserialize, POJOs from this or that class differently depending on your needs
 
1:07 PM
@ballBreaker whatsup
 
fge
For instance, this is why there exist jars in Jackson which allow you to correctly {de,}serialize JSR 310 datatypes even though the base Jackson does not
Since this is not limited to Jackson modules alone, it means you can use that mechanism for your own purposes
 
Does anyone here have experience in Cassandra codebase ?
 
@ColdFire Just got in to work 20 mins ago, need to show up early now or I'll get fired lol ^^
 
@buzzLY Fly Away.. :P
 
1:09 PM
@ita
 
Is it possible to tell the ObjectMapper "use this serializer and not that, for the same POJO"?
 
@ItachiUchiha that means no for you !
 
fge
@MadaraUchiha yes; just configure the mapper accordingly
 
@buzzLY Yes :)
 
@fge I'll expand
I have a singleton bean ObjectMapper
That will need to serialize both types, normal and filtered.
I can't do this configuration at construction time, but at the time I call writeValueAsString()
And it needs to be on a per-run basis
Can I do that?
 
fge
1:11 PM
@MadaraUchiha a singleton will not be able to cover both needs; you'll need a custom mapper for each run
If you can afford it performance wise, and my guess is that you can, just do so
 
@fge It's not the performance I'm worried about in this case.
 
fge
What is it then?
 
We currently have this one ObjectMapper instance for the entire system
If I make another one, we would have this one ObjectMapper instance for the entire system, except for this one other thing, where I use this other one.
That "except" makes me edgy
I would ideally expect there to be something like mapper.using(MyPojo.class, someSerializer).writeValueAsString(myPojo)
 
fge
Well then it means that if you can create your "someSerializer" at runtime, the problem is solved, right?
Actually I have never used the .using() method in Jackson
 
Morning, Java!
 
1:24 PM
hello there
 
@fge There's a .using() method?
 
fge
Wait; I thought this was actual code
But if it isn't, then use a Module
 
Hey @Gem
 
@fge But a module changes the ObjectMapper's state, right?
I can't have two modules pointing at the same class
And giving it two different serializers?
Or can I use a module just for this run?
 
fge
Which is why I say to create a different Mapper each time
It's not as if creating a new (Object)Mapper were that expensive
Don't bother
 
1:31 PM
@fge I'll ask older and wiser if that would be OK with the rest of the system.
 
'sup?
 
hi
 
fge
@MadaraUchiha as if I weren't old enough :p Not sure about "wise" though :p
Anyway, given your situation this is how I'd go about it
 
1:51 PM
@fge "older and wiser" is a general name for coworkers who know the system better than you.
 
fge
Fair enough
 
@MadaraUchiha He doesn't know what "better than him" means
;P
 
fge
@Gemtastic I know so little in general that it's not even funny; even in domains which I have studied at length
But the little I know and I am sure about I can at least share :p
 
is there any way in a JFileChooser to add automatically an extension to the input before even clicking any button?
e.g. It opens and one types "test" and the inputline automatically shows "test.txt" and if one continues writing for ex. "test_1" it automatically shows "test_1.txt"?
 
2:07 PM
@motaa I do not exactly remember how a JFileChooser works, but I am sure it is possible.
 
k thanks I will keep checking the stack :) not how to call the input box :D
 
2:31 PM
Is there a predicate shortcut for ignored -> true?
Similar to Function.identity() for o -> o
Also, would you say that the following is an acceptable practice?
public static void writeMode() throws IOException {
  writeFilteredMode(o -> true);
}

public static void writeFilteredMode(Predicate<LoaderProperty> modeFilter) throws IOException {
  // snip
  for (final LoaderProperty property : propertyList) {
    if (modeFilter.test(property)) {
      // do something with property
    }
  }
  //snip
}
 
something like propertyList().stream().filter(modeFilter).foreach(p -> doIt(p));?
 
@Nicktar doIt throws
Not worth it.
(Hence the throws IOException)
 
fge
2:50 PM
if you use throwing-lambdas there is ThrowingConsumer, but...
 
3:09 PM
@fge I do have throwing-lambdas
But I don't have tests for this part yet, so I'd like to stick to automated refactorings as much as possible.
That's a good idea though, after I get tests in place, I'll definitely do that.
Should be nicer looking than what I have at the moment.
 
3:29 PM
hii
i declare a class A object in the Class B . does Class A object act like instance Variable for class B? if yes that mean it can access all instance variable of Class A?
 
@Lalitkumar the way you phrase it is a bit confusing but if I've understood correctly then yes, as long as visibility rules allow it
 
fge
@Lalitkumar you seem to be misunderstanding how inner classes work in Java; and in particular what it means to have an inner class defined as static or not
 
@fge I didn't understand that as an inner class, but as field
"declare class A object in the class B" sounds like a field to me
 
fge
3:45 PM
@Tavo yet there is a fundamental difference in behaviour depending on whether you declare an inner class as static or not
 
agreed
 
fge
Grr
Sorry for the edits
 
lol
I keep buzzing :P
no worries
 
fge
Yeah, hence my apology -- my fault :(
 
@fge Ended up doing as you say, using different ObjectMappers, it looks a lot cleaner than my decorator solution, cheers.
 
4:06 PM
@Tavo this is code hastebin.com/keyopuyira.vala
Earlier i asked u question "i declare a class A object in the Class B . does Class A object act like instance Variable for class B? if yes that mean it can access all instance variable of Class A?"
Replace class A by Incm and Class B by obj
@fge
 
4:29 PM
@Tavo You ever watch a Bill Burr standup? Guy is my spirit animal
 
4:55 PM
@Lalitkumar Yes
Objects expose their public methods and fields to the outside world. So anyone with a reference to an instance (in your case, the instance of obj having an instance of Incm), can access all of their public members.
 
thk buddy .how i missed such an important concept while learning java .
@MadaraUchiha
 
@Lalitkumar You should definitely read Effective Java
It should cover all your bases.
 
Currently i m reading herbert schildt java beginner
Some Suggestion abt Book?
 
@Lalitkumar Not overly familiar with it\
Maybe other folks in the room are.
 
ok dude
@MadaraUchiha would u like tell me why m i able to access private instance Variable in the code hastebin.com/locosoyuto.vala
 
 
3 hours later…
8:38 PM
Hmmm
Does the fact that Clojure generates Java bytecode that runs in the JVM means that for every valid Clojure program, there's a valid Java program that would generate the same bytecode?
 
fge
8:59 PM
@MadaraUchiha my guess would be no
 
@fge How come?
Given that Intellij comes with an on-board decompiler, I'd guess yes
(But I'm not sure, obviously :P)
 
fge
Well, the classes etc differ between one base language and the other for one
So, exactly the same bytecode, I doubt it
 

« first day (2132 days earlier)      last day (2814 days later) »