• 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: 22185
38
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
Sheriff
Posts: 53779
128
  • 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.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!