Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

java.io.FileFilter - accept?

 
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?
 
Marshal
Posts: 25822
69
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.
 
Marshal
Posts: 70286
282
  • 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 wasn't my idea to go to some crazy nightclub in the middle of nowhere. I just wanted to stay home and cuddle with this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic