« first day (3063 days earlier)      last day (1884 days later) » 

12:00 AM
The world is coming to an end. Please log off. (source)
 
12:19 AM
farts
 
 
6 hours later…
6:19 AM
reads a book
 
Zoe
6:57 AM
@OakBot the world is a bit like SAO: We can't log out.
 
@Zoe Type /help to see all my commands.
 
Zoe
Yeah yeah xd
 
@SanjayKumar Welcome to the Java Chat, the room for Java enthusiasts! Please use a code snippet tool when posting code snippets. If you have an Android question, you're in the wrong place! And remember: this is not tech support! Thanks for visiting and have fun! :D
 
i have a question
 
7:23 AM
@SanjayKumar just us here, but go ahead
if I can answer, I will
 
@Neil DENIED!
 
@KarelG I JUST WANNA HELP YOU! ._.
 
me? Me no help. No vodka, no help.
 
I read that with a Russian accent for some reason
 
7:49 AM
Poland!
PPPPPP OOOOOOO LLLLL AAAAAAAAAAAAA nnnnnnnnn ddddddd ....
 
8:30 AM
is there a way in Kotlin to assign class members to the primary constructor?
I need to pass a predicate, and writing it in the header is a little ugly
Also I could reuse it, so it has twice the advantage making it a member
 
8:44 AM
ask @Wietlol , the kotlin boy
 
8:56 AM
morn
 
morn
 
9:17 AM
morn
 
morn
 
morn
 
9:43 AM
\o
 
o/
 
o/
 
/fatcat
 
o/
 
Is that still your cat @Hans1984 ? ;)
 
yeah
no its actually me
but not this one
the one sitting on the bed
/fatcat
 
lol ,not this one
this is a gigantic cat
 
hans!
it is not a fat cat
 
9:46 AM
its a lion
 
It is T H I C
 
oh yeah right
the womans hand looks gigantic too
something is wrong with this pic
great the using chemicals to renovate the office next door
and now we are getting headaches over here
ugh
although all doors are closed
 
that does not keep that air out ...
 
yeah.. I can tell by now
x(
 
or are your office doors resistant for bio-gas attack?
open the windows if it is possible
 
9:58 AM
It seems like they are not
I did open the window behind me already
 
such doors are rare :P
 
but i got headaches already
uggh
 
is there any air flow? opening one window does not help a lot. Better to open the door or second window
 
tomorrow i will go to work with a gas mask on
we cant realy open the door
its one with those chipcards
and also the door leeds to the hallway and the office is next door
so the hallway is contaminated already
we will turn into mindless zombis soon
bye world !
 
How can I convert Character.isWhitespace to a predicate in kotlin?
it doesn't seem to want to take Character::isWhitespace as a Predicate<Int>
 
10:27 AM
@Neil That's because it's an IntPredicate, not Predicate<Integer>
 
> Unresolved reference. None of the following candidates is applicable because of receiver type mismatch:
public fun Char.isWhitespace(): Boolean defined in kotlin.text
Still doesn't like return Character::isWhitespace
apparently it requires a KFunction1<Char, Boolean>?
 
10:49 AM
hi
 
yo
 
is possible to get a recursive function to run in parallel, where each frame of the stack is run by a different thread and then you just stitch the result back together again upon completion. java has this ability to multithread correct or is it not a seamless implementation.
seems like it might be useful when backtracking
 
@Zoe I just saw your moderator proposal lol
 
11:31 AM
@Rick strikes me as an extraordinarily bad idea
but it may be possible if each recursive call spawned another thread to call itself
 
11:43 AM
there is a lot work to change enums into a class instance when it is used often in code :|
 
the only reason you'd need to change enums into a class instance is you no longer need them as singletons
 
Zoe
@Neoares ^^"
@Neil isn't it an extension function?
 
@Zoe I just used an (Int) -> Boolean
apparently that's not the same as a IntPredicate
but it works for me
 
Zoe
Ooh, from Kotlin ^^"
Nvm then
 
12:00 PM
Employees who have more control over the layout and design of their workspace are healthier and happier in the office. (source)
 
posted on March 13, 2019

archive - contact - sexy exciting merchandise - search - about ← previousMarch 13th, 2019nextMarch 13th, 2019: DINOSAUR COMICS BOOK ARE ON SUPERSALE! THIS NEVER HAPPENS– Ryan

 
Is Oak complaining about his working conditions ?
 
He sounds unhappy with his current job
Subtle, Oakbot.. very subtle
 
yeah, hes a smart bot after all
 
Zoe
12:25 PM
@Neil isn't it Char::isWhitespace
@Neil I think we need to take this to @Michael
 
@Zoe that doesn't return an IntPredicate either
 
Zoe
Oh
 
12:52 PM
@Neil you assign a member to a class
you provide a primary constructor for members
you dont assign members to a constructor
 
@Wietlol ok, putting it in a different way
if you were passing a predicate to a super class and it was rather bulky
would there be no elegant way of doing this?
I could define it directly in the parameter passed to the super class, but I'd prefer to have it as a class member or something so it's a little nicer to look at
 
can you show an example?
I have no clue what you mean
 
suppose you have a token handler base class, which eats up letters so long as each letter meets a criteria determined by a predicate passed in the constructor
any class deriving from this class must therefore pass a predicate
 
can you show example code?
 
no, not really, I got around it by adding an abstract function
it's not that complex, I promise.. your base class requires a lambda of some sort as a parameter.. this lambda is bulky (in my case not even so much, but that's beside the point)
 
12:59 PM
I dont understand words, I understand examples
/shrug
 
¯\_(ツ)_/¯
 
ok
/shrug
 
examples is a word you panther
 
class Neil(
	pred: (Char) -> Boolean
) : BaseNeil(pred)
@d0n.key words != word, you bafoon
@Neil I dont find this particularly ugly
 
@Wietlol No, the Neil class defines the lambda being passed
it isn't a parameter
 
1:02 PM
it what?
why?
 
because my base class, using a predicate, reads each character one by one and so long as it returns true, it eats it up and adds it to a token
 
why not make it a member method?
 
it lets me say, define a derived class which says, here: take this predicate which matches whitespace characters.. and now you have a tokenizer which matches whitespace characters
 
you should use methods for inheritance
you should use functions for composition
you actually use functions for inheritance
that doesnt make much sense
 
because I want to be able to distinguish a whitespace token from a number token
I can't do that if the predicate is the only thing that changes
and I don't think what distinguishes the two should be set as a property
 
1:06 PM
class Neil : BaseNeil(::foo)
{
	companion object
	{
		fun foo(char: Char): Boolean = char.isWhitespace()
	}
}
this is sort of how you want it
but now foo is a function(*), not a method
 
no, that's fugly
 
@Neil but that without the companion object is how you intended it to be, right?
 
@Wietlol Yes, not having to declare the lambda directly in the place of your ::foo
maybe that's the only way of achieving this then
 
well... I would not use a property, but a method
that is what your issue's roots are at
and that you are not using interfaces, but classes
silly Neil
 
well that's how I addressed it
sometimes you have to write classes you know.. if the whole thing were interfaces, nothing would work
 
1:11 PM
@Neil I refuse to accept that
what is BaseNeil doing?
I assume it is an abstract class
 
Zoe
@Wietlol void* func = &Neil.foo
 
I need a class which eats up all whitespace characters and returns a whitespace token.. I need another class which eats up all numbers and periods, (validates), and returns a number token.. etc.
they all have something in common
 
@Zoe no u
 
given a predicate, they consume letters until it returns false
seems reason enough to use a base class, no?
 
Zoe
@Wietlol I'm not a void*, I'm a wolf. I see how you might get confused though JavaScript ;)
 
1:14 PM
@Neil can you show BaseNeil?
@Zoe I said "foo is a function(*)"
but foo is not actually a function
it is a method
 
Zoe
Aren't they all?
 
but it is used as a function right there
in kotlin, there is a difference between a function and a method
 
Zoe
Your argument is void* in the end ;)
 
yes, methods are functions, but functions are not always methods
class Method : Function
 
1:15 PM
token handler is an interface which has canHandle and handle
 
Zoe
@Wietlol that's Functions, not functions
 
if canHandle returns true, then handle is supposed to return a token
 
@Neil are you sure?
can you show me the TokenHanadler class?
 
@Wietlol Are you sure?
 
wait
ye, im pretty sure
 
1:16 PM
oh, yeah you're right, it's a class
abstract class TokenHandler(val ignoreToken: Boolean) {
    abstract fun handle(reader : PeekReader) : Token
    abstract fun canHandle(reader : PeekReader) : Boolean
}
 
ok...
so... this TokenHandler.... doesnt use ignoreToken
so, its an api member
this class can be an interface
 
I suppose it could be, sure
 
interface TokenHandler
{
	val ignoreToken: Boolean
	fun handle(reader: PeekReader): Token
	fun canHandle(reader: PeekReader): Boolean
}
 
ah no, see it's relevant
 
wait... YOU WOT!?
> class ConstantTokenHandler(val ignore: Boolean = false) : TokenHandler(ignore)
you realize that that "ignore" value is also a property, right?
 
1:19 PM
The class generating the token cycles through the token handlers, and it must know if it is a whitespace token
 
so, you now have ignore AND ignoreToken
(completely irrelevant, but still)
ConstantTokenHandler can also be an interface
 
oh
I thought that's how you passed it down
No, because it's generating a token for me
the derived class doesn't do that.. it simply determines what consists of the type of token it represents
 
@Neil remove the val from it, and then it is
add the val and it creates a new property
@Neil why cant it be an interface?
 
1 min ago, by Neil
No, because it's generating a token for me
 
so?
 
1:22 PM
so if it has an implementation, it's not a freakin' interface
 
hehe
interface ConstantTokenHandler : TokenHandler
{
	override fun handle(reader: PeekReader): Token
	{
		val sb = StringBuilder()
		val predicate = getTokenPredicate()
		while (predicate(reader.peek()))
		{
			sb.append(Character.toChars(reader.read()))
		}
		return Token(sb.toString())
	}

	override fun canHandle(reader: PeekReader): Boolean
	{
		val predicate = getTokenPredicate()
		return predicate(reader.peek())
	}

	fun getTokenPredicate(): (Int) -> Boolean
}
you have much to learn, my young padawan
 
yeah, not doing that
 
why not?
 
because for all intents and purposes, it's a class, not an interface
 
it is not
it is an interface
 
1:23 PM
so even if you legally can declare it an interface, it's confusing
 
@Neil only if you are stupid and think that "interface" only has one meaning
you are dealing with a generalized module class
a module class doesnt exist in kotlin, so we use an interface instead
there is no reason to use an abstract class over an interface in this scenario
 
@Wietlol so when would you use a class?
 
when I need an actual thing
keep in mind, this wasnt a full class
this was an abstract class
it wasnt meant to be an actual thing in the first place
 
again, maybe I'm missing something here.. what is the problem with using an abstract class that I'm clearly remedying by using an interface instead?
 
when you get rid of the abstract class, you get rid of your constructor
when you get rid of your constructor, you get rid of your issues with the constructor
 
1:27 PM
and yet, I do need the predicate here
you propose I make it a property and assign it in the constructor?
 
class Neil : BaseNeil
{
	override val pred = Char::isWhitespace
}

interface BaseNeil
{
	val pred: (Char) -> Boolean
}
iNtErFaCeS
 
and this somehow weren't possible if BaseNeil weren't an interface?
 
ofc it was
but you needed to convert to the interface religion anyway
abusing abstract classes is bad
composition frowns upon (abstract) classes
 
not "converting to the interface cult" just because
 
you should
the earlier you do, the less damage you have to repair
making an interface an abstract class for reason "I expect it to be a class" is also not a strong point imho
there are still reasons to use an abstract class
one of them is a JVM issue
another is a kotlin language design issue
i havent found more tho
so, in the ende, abstract classes would be no more
at that point, classes being no more is close as well
only JVM interop would be an issue
 
1:33 PM
it's only a problem if you use abstract classes throughout your code where you use it
if it's assisting in your implementing classes, then worst case scenario, that's all you'll have to change later
if you had that type of problem, then conceptually you were trying to make an implementation fit where it shouldn't
 
even if it is assisting your implementing classes, it still is an issue
 
@Neil Don't give him any ideas. Oak loves his job.
 
it must be a full assist, no partial assists
because you cant combine the abstract classes
you can combine the interfaces
 
@Wietlol I'll take the risk.. I'm a daredevil you see
Though I'll give it to you.. TokenHandler is better off as an interface
 
I see
 
1:36 PM
I honestly thought it already was
 
a padawan that refuses to accept his master's advice
troubled, your mind is
find the light, you will
keep practising, you must
 
no offense, but when it comes to Java, I'm no padawan and you insist that using interfaces everywhere is the way to go
when you say the same is true for Kotlin, I have my reservations
 
padawans, we all are
 
except Yoda
 
except Yoda
 
1:39 PM
And Darth Insidious
 
and Darth Plagueis
 
And Ben Kenobi
well except all of them except for the children
 
children, we still are
 
but they were slaughtered
@Wietlol except Yoda
 
a game of preference, we play
 
1:40 PM
And Darth Insidious
And Ben Kenobi
 
anyway, comparing kotlin to java, you should still favor interfaces
the only thing that you have to find a good balance in is interfaces vs (x) -> Y (functions)
bring balance to kotlin, we will
 
I do like that you can define members in interfaces which must be defined
that does mean I don't have to make methods out of them
 
you define the contract of members in an interface
you define the actual members in a class
(that is a design issue of kotlin)
and a reason abstract classes are still a thing
 
Timelapse of Patrick Stewart aging: old.reddit.com/r/gifs/comments/b07ofu/…
 
does anyone know a tool online that converts switch case to if / else statements?
I have a nested one. Seems convulated
 
1:56 PM
@KarelG closure compiler
I am not sure if it will unwrap it.
 
gotcha do a hand job then
7
 
@KarelG yep :P
 
@KarelG May that be visible to your future employers for years to come :)
 
pfft context...
it is there!
 
2:03 PM
I'm sure they'll check the context of that message
count on it ;) ;) ;)
 
nope.. all it now needs a twitter hashtag
 
Zoe
#ContextIsforNoobs
@SurajRao for you ^ :p
 
thank you
 
Zoe
@Rick not yet
 
2:18 PM
I wonder... Can we get KarelG banned for that? :D
 
@geisterfurz007 for detangling code
 
For the starred message!
 
What is a full path without the last filename called?
 
directory of the file?
 
but a directory can be a single directory name or full path till the directory
 
2:22 PM
@gaurav empty directory
 
does anyone know how to add Apache Tika to a project in IntelliJ? I tried adding the jar files for core and parser, but I'm getting Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/tika/Tika
 
use maven.
 
@erotavlas Did you just put it in a directory of your project or did you actually add them as library?
 
2:32 PM
I added them to the library in the module settings
sorry as library
I removed it now...and I'm trying to add it from Maven instead
 
2:55 PM
o/
 
\o
 
3:46 PM
 
I have a problem with circular reference in my project
which approach (apart from redesign, will do that later) should I take?
Both classes have constructor injection
 
4:03 PM
In IntelliJ when I create my Artifacts from a Console Application, it asks me what the main class is....does this mean that the main class gets included in the output jar file?
 
the main class is used to load the java application. If you have multiple, you have to pick one which is used as launcher when the jar file gets created
a jar without a main class is a library
that is possible. Just don't specify it
 
so I can leave it empty? I don't want the jar file to have a main class (its just a library that I created use the console app for debugging purpose)
 
4:22 PM
@erotavlas sure. The jar file is then a library as said.
 
ok thanks, I created the artifacts but when I try using it, I get an error Configure failed (NoClassDefFoundError): com/company/TikaFileTypeDetector
 
@erotavlas you can put the testing part in a testing source directory
 
@Wietlol ok thanks that's good to know
in artifacts output layout do I have to specify something for class path?
 
4:41 PM
posted on March 13, 2019 by CommitStrip

 
 
1 hour later…
5:47 PM
hey guys, how could one do such a thing?
public <T> Class<T[]> foo(Class<T> clazz) {
return clazz[].class;
}
I hope you get the idea
 
5:59 PM
other than that nasty approach:
public <T> Class<T[]> foo(Class<T> clazz) throws Exception {
return Class.forName("[L" + clazz.getName() + ";");
}
 
Arrays with generics are tricky. May not be possible.
I shudder to think why you need to write such code.
 
there's some ugly wrapper around the Gson lib and I want to pretify it a little bit
for example, theres a function signed like this: static Object stringToEntity(String json, Type clazz)
I'm trying to make functions like:
static <T> T[] getArray(String json, Class<T> clazz) // note that i'm not using Class<T[]>
static <T> List<T> getList(String json, Class<T> clazz)
static <T> T getObject(String json) is already done due its simplicity
any ideas?
btw, using Gson's TypeToken has led to me a nasty bug which I'm not going to talk about for now, thats why my struggle
 
 
3 hours later…
9:37 PM
dont use array, use list (ArrayList for example)
arrays are nutorious
 
9:47 PM
Hi there everybody
 
9:58 PM
I have a question regarding Spring. When is AOP appropriate vs using generics?
And method reflection?
Seems like there's an overlap of the problem domain, I'm just unsure of the problems each attempts to solve distinctly.
 

« first day (3063 days earlier)      last day (1884 days later) »