This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

java.io.FileFilter - accept?  RSS feed

 
Roy Pozarelli
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was just curious about the following:
java.io.FileFilter:



Why was this named accept? It seems to me that it should be named like a Predicate (ie. method named "test") since it returns a boolean, as opposed to a Consumer that uses the name "accept" but returns void. I thought this might be a historical thing since java.io was around from early on, but @FunctionalInterface is recent so it seems to me that this is not the case.

Your thoughts?
 
Paul Clapham
Sheriff
Posts: 22480
43
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you're right, it must be a historical thing. The FileFilter interface has been around since Java 1.2 according to the documentation, and Oracle must have applied the @FunctionalInterface annotation when Java 8 was released. Obviously renaming the method at that point would have been a big no-no.
 
Campbell Ritchie
Marshal
Posts: 55698
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, that is a problem about interfaces. Once you have released them on an unsuspecting world, you cannot change them. At least not until default methods appeared in Java8.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!