How do filters work?

Discussion in 'Developer Support' started by Zallen93, Apr 1, 2015.

  1. Zallen93

    Joined:
    Jul 17, 2014
    Messages:
    9
    Likes Received:
    0
    Hi,

    Sorry to ask such a vague question but I see them about a bit but not sure what they really are, when is best to use them and how exactly to use them. I'm not expecting a full blown guide but maybe a little example then I can take it from there.

    Many thanks!
     
  2. SlashnHax

    SlashnHax The Chosen One

    Joined:
    Dec 10, 2014
    Messages:
    2,783
    Likes Received:
    734
    The accept method in a filter determines whether to keep that object or not, if accept returns true it's kept, if it returns false it is removed.

    They can be used for stuff like, filtering out Npcs that are already in combat, either by checking if they have a health gauge, or have a target, or are being targeted.
     
    Geashaw likes this.
  3. Zallen93

    Joined:
    Jul 17, 2014
    Messages:
    9
    Likes Received:
    0
    Ah ok awesome, I just got tied up a bit because I saw the usual way to get objects then I saw the filter method and thought to myself which way is better - but I see now each one has its uses in certain circumstances. Thank you :)
     
  4. Arbiter

    Arbiter Mod Automation

    Joined:
    Jul 26, 2013
    Messages:
    2,425
    Likes Received:
    1,006
    @Zallen93 If you're developing for RuneMate or are generally a fun guy who's interested in programming you should highly consider joining our Skype dev chat. We would have answered your question within seconds. Hit me up with your Skype via PM if you're interested. :)
     
  5. Overflow

    Joined:
    Mar 26, 2014
    Messages:
    23
    Likes Received:
    1
    One question i have is since the client supports java 8 and its actually recommended. Why is there a seperate filter, sort and query api, instead of using generic collections classes and let the scripter use the new collections streams api?
     
  6. Arbiter

    Arbiter Mod Automation

    Joined:
    Jul 26, 2013
    Messages:
    2,425
    Likes Received:
    1,006
    The query API was developed before we started forcing Java 8. @Cloud can speak on the merits of the query API over standard streams.
     
  7. Savior

    Savior Espresso Ghetto

    Joined:
    Nov 17, 2014
    Messages:
    1,951
    Likes Received:
    653
    Why aren't Lambdas working for filters?
     
  8. SlashnHax

    SlashnHax The Chosen One

    Joined:
    Dec 10, 2014
    Messages:
    2,783
    Likes Received:
    734
    Because filters are abstract classes, not functional interfaces
     

Share This Page

Loading...