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 ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown - accept?

Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was just curious about the following:

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 was around from early on, but @FunctionalInterface is recent so it seems to me that this is not the case.

Your thoughts?
Posts: 25822
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.
Posts: 70286
  • 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
    Bookmark Topic Watch Topic
  • New Topic