Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[Snippet ]Predicate <-> Filter adapter

Featured Replies

Adapts an OSBot Filter to work as a Java Util Predicate and vice versa.

 

Useful if you don't wan't to rewrite your Predicate and / or Filter libraries but still want to enjoy the benefits provided by both worlds.

 

If someone has a cleaner method, please do let me know!

public class FilterPredicate<V> implements Filter<V>, Predicate<V> {
	
	protected boolean _test(V value) {
		return false;
	}

	@Override
	public boolean match(V value) {
		return _test(value);
	}

	@Override
	public boolean test(V value) {
		return _test(value);
	}

	// Virtual constructor for OSBot Filter.
	public FilterPredicate<V> fromFilter(Filter<V> filter) {
		return new FilterPredicate<V>() {
			@Override
			protected boolean _test(V value) {
				return filter.match(value);
			}
		};
	}

	// Virtual constructor for Java Util Predicate.
	public FilterPredicate<V> fromPredicate(Predicate<V> predicate) {
		return new FilterPredicate<V>() {
			@Override
			protected boolean _test(V value) {
				return predicate.test(value);
			}
		};
	}
	
}

Examples:

 * EXAMPLE A:

  Predicate<V> predicate = ...
  Filter<V> filter = new FilterPredicate<V>().fromPredicate(predicate);

 * EXAMPLE B:
 
  Filter<V> filter = ...
  Predicate<V> predicate = new FilterPredicate<V>().fromFilter(filter);
  
 * EXAMPLE C:
  
  PredicateFilter<V> god = new PredicateFilter<V>().fromPredicate(lambda);
  god.predicate_specific_method();
  god.filter_specific_method();

Edited by Traum

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.