Reduce Predicate usage

This commit is contained in:
Magnus Ulf 2019-05-19 21:19:06 +02:00
parent eccfb6cdab
commit 32f4fe0c33
8 changed files with 6 additions and 57 deletions

View File

@ -1,7 +1,6 @@
package com.massivecraft.massivecore; package com.massivecraft.massivecore;
import com.massivecraft.massivecore.collections.MassiveList; import com.massivecraft.massivecore.collections.MassiveList;
import com.massivecraft.massivecore.predicate.Predicate;
import com.massivecraft.massivecore.predicate.PredicateIntegration; import com.massivecraft.massivecore.predicate.PredicateIntegration;
import com.massivecraft.massivecore.util.Txt; import com.massivecraft.massivecore.util.Txt;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -13,6 +12,7 @@ import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.function.Predicate;
public class Integration extends Engine public class Integration extends Engine
{ {
@ -56,7 +56,7 @@ public class Integration extends Engine
// Calc // Calc
if (integrationActive == null) if (integrationActive == null)
{ {
integrationActive = this.getPredicate().apply(this); integrationActive = this.getPredicate().test(this);
} }
// NoChange // NoChange

View File

@ -1,9 +1,10 @@
package com.massivecraft.massivecore.command.requirement; package com.massivecraft.massivecore.command.requirement;
import com.massivecraft.massivecore.command.MassiveCommand; import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.predicate.Predicate;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import java.util.function.Predicate;
public interface Requirement extends Predicate<CommandSender> public interface Requirement extends Predicate<CommandSender>
{ {
boolean apply(CommandSender sender, MassiveCommand command); boolean apply(CommandSender sender, MassiveCommand command);

View File

@ -15,7 +15,7 @@ public abstract class RequirementAbstract implements Requirement, Serializable
// -------------------------------------------- // // -------------------------------------------- //
@Override @Override
public boolean apply(CommandSender sender) public boolean test(CommandSender sender)
{ {
return this.apply(sender, null); return this.apply(sender, null);
} }

View File

@ -1,7 +1,6 @@
package com.massivecraft.massivecore.event; package com.massivecraft.massivecore.event;
import com.massivecraft.massivecore.collections.MassiveList; import com.massivecraft.massivecore.collections.MassiveList;
import com.massivecraft.massivecore.predicate.Predicate;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -85,12 +84,6 @@ public class EventMassiveCoreLorePriority extends EventMassiveCore
} }
} }
@Deprecated
public void setPriorityByPredicate(Predicate<String> predicate, int priority)
{
setPriorityByPredicate((java.util.function.Predicate<String>) predicate, priority);
}
public void setPriorityByPrefix(final String prefix, int priority) public void setPriorityByPrefix(final String prefix, int priority)
{ {
java.util.function.Predicate<String> predicate = prefix::startsWith; java.util.function.Predicate<String> predicate = prefix::startsWith;

View File

@ -11,7 +11,6 @@ import com.massivecraft.massivecore.adapter.AdapterMsonEventFix;
import com.massivecraft.massivecore.collections.MassiveList; import com.massivecraft.massivecore.collections.MassiveList;
import com.massivecraft.massivecore.command.MassiveCommand; import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.mixin.MixinMessage; import com.massivecraft.massivecore.mixin.MixinMessage;
import com.massivecraft.massivecore.predicate.Predicate;
import com.massivecraft.massivecore.util.MUtil; import com.massivecraft.massivecore.util.MUtil;
import com.massivecraft.massivecore.util.Txt; import com.massivecraft.massivecore.util.Txt;
import org.apache.commons.lang.mutable.MutableInt; import org.apache.commons.lang.mutable.MutableInt;
@ -26,6 +25,7 @@ import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.ListIterator; import java.util.ListIterator;
import java.util.Objects; import java.util.Objects;
import java.util.function.Predicate;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;

View File

@ -1,7 +1,5 @@
package com.massivecraft.massivecore.store; package com.massivecraft.massivecore.store;
import com.massivecraft.massivecore.predicate.Predicate;
import java.util.Collection; import java.util.Collection;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
@ -73,21 +71,6 @@ public interface EntityContainer<E>
List<E> getAll(Integer limit, Integer offset); List<E> getAll(Integer limit, Integer offset);
List<E> getAll(Integer limit); List<E> getAll(Integer limit);
// OLD PREDICATE
@Deprecated List<E> getAll(Predicate<? super E> where, Comparator<? super E> orderby, Integer limit, Integer offset);
@Deprecated List<E> getAll(Predicate<? super E> where, Comparator<? super E> orderby, Integer limit);
@Deprecated List<E> getAll(Predicate<? super E> where, Comparator<? super E> orderby);
@Deprecated List<E> getAll(Predicate<? super E> where, Integer limit, Integer offset);
@Deprecated List<E> getAll(Predicate<? super E> where, Integer limit);
@Deprecated List<E> getAll(Predicate<? super E> where);
@Deprecated List<E> getAll(Iterable<?> oids, Predicate<? super E> where, Comparator<? super E> orderby, Integer limit, Integer offset);
@Deprecated List<E> getAll(Iterable<?> oids, Predicate<? super E> where, Comparator<? super E> orderby, Integer limit);
@Deprecated List<E> getAll(Iterable<?> oids, Predicate<? super E> where, Comparator<? super E> orderby);
@Deprecated List<E> getAll(Iterable<?> oids, Predicate<? super E> where, Integer limit, Integer offset);
@Deprecated List<E> getAll(Iterable<?> oids, Predicate<? super E> where, Integer limit);
@Deprecated List<E> getAll(Iterable<?> oids, Predicate<? super E> where);
// -------------------------------------------- // // -------------------------------------------- //
// BEHAVIOR // BEHAVIOR
// -------------------------------------------- // // -------------------------------------------- //

View File

@ -145,21 +145,6 @@ public abstract class EntityContainerAbstract<E extends EntityInternal<E>> imple
@Override public List<E> getAll(Integer limit, Integer offset) { return MUtil.transform(this.getAll(), limit, offset); } @Override public List<E> getAll(Integer limit, Integer offset) { return MUtil.transform(this.getAll(), limit, offset); }
@Override public List<E> getAll(Integer limit) { return MUtil.transform(this.getAll(), limit); } @Override public List<E> getAll(Integer limit) { return MUtil.transform(this.getAll(), limit); }
// OLD PREDICATE
@Deprecated @Override public List<E> getAll(Iterable<?> oids, com.massivecraft.massivecore.predicate.Predicate<? super E> where, Comparator<? super E> orderby, Integer limit, Integer offset) { return MUtil.transform(this.getAll(oids), where, orderby, limit, offset); }
@Deprecated @Override public List<E> getAll(Iterable<?> oids, com.massivecraft.massivecore.predicate.Predicate<? super E> where, Comparator<? super E> orderby, Integer limit) { return MUtil.transform(this.getAll(oids), where, orderby, limit); }
@Deprecated @Override public List<E> getAll(Iterable<?> oids, com.massivecraft.massivecore.predicate.Predicate<? super E> where, Comparator<? super E> orderby) { return MUtil.transform(this.getAll(oids), where, orderby); }
@Deprecated @Override public List<E> getAll(Iterable<?> oids, com.massivecraft.massivecore.predicate.Predicate<? super E> where, Integer limit, Integer offset) { return MUtil.transform(this.getAll(oids), where, limit, offset); }
@Deprecated @Override public List<E> getAll(Iterable<?> oids, com.massivecraft.massivecore.predicate.Predicate<? super E> where, Integer limit) { return MUtil.transform(this.getAll(oids), where, limit); }
@Deprecated @Override public List<E> getAll(Iterable<?> oids, com.massivecraft.massivecore.predicate.Predicate<? super E> where) { return MUtil.transform(this.getAll(oids), where); }
@Deprecated @Override public List<E> getAll(com.massivecraft.massivecore.predicate.Predicate<? super E> where, Comparator<? super E> orderby, Integer limit, Integer offset) { return MUtil.transform(this.getAll(), where, orderby, limit, offset); }
@Deprecated @Override public List<E> getAll(com.massivecraft.massivecore.predicate.Predicate<? super E> where, Comparator<? super E> orderby, Integer limit) { return MUtil.transform(this.getAll(), where, orderby, limit); }
@Deprecated @Override public List<E> getAll(com.massivecraft.massivecore.predicate.Predicate<? super E> where, Comparator<? super E> orderby) { return MUtil.transform(this.getAll(), where, orderby); }
@Deprecated @Override public List<E> getAll(com.massivecraft.massivecore.predicate.Predicate<? super E> where, Integer limit, Integer offset) { return MUtil.transform(this.getAll(), where, limit, offset); }
@Deprecated @Override public List<E> getAll(com.massivecraft.massivecore.predicate.Predicate<? super E> where, Integer limit) { return MUtil.transform(this.getAll(), where, limit); }
@Deprecated @Override public List<E> getAll(com.massivecraft.massivecore.predicate.Predicate<? super E> where) { return MUtil.transform(this.getAll(), where); }
// -------------------------------------------- // // -------------------------------------------- //
// BEHAVIOR // BEHAVIOR
// -------------------------------------------- // // -------------------------------------------- //

View File

@ -1408,12 +1408,6 @@ public class MUtil
// TRANSFORM // TRANSFORM
// -------------------------------------------- // // -------------------------------------------- //
@Deprecated
public static <T> List<T> transform(Iterable<T> items, com.massivecraft.massivecore.predicate.Predicate<? super T> where, Comparator<? super T> orderby, Integer limit, Integer offset)
{
return transform(items, (Predicate<? super T>) where, orderby, limit, offset);
}
public static <T> List<T> transform(Iterable<T> items, Predicate<? super T> where, Comparator<? super T> orderby, Integer limit, Integer offset) public static <T> List<T> transform(Iterable<T> items, Predicate<? super T> where, Comparator<? super T> orderby, Integer limit, Integer offset)
{ {
// Collection // Collection
@ -1512,13 +1506,6 @@ public class MUtil
public static <T> List<T> transform(Iterable<T> items, Integer limit) { return transform(items, null, null, limit, null); } public static <T> List<T> transform(Iterable<T> items, Integer limit) { return transform(items, null, null, limit, null); }
public static <T> List<T> transform(Iterable<T> items, Integer limit, Integer offset) { return transform(items, null, null, limit, offset); } public static <T> List<T> transform(Iterable<T> items, Integer limit, Integer offset) { return transform(items, null, null, limit, offset); }
// OLD PREDICATE
@Deprecated public static <T> List<T> transform(Iterable<T> items, com.massivecraft.massivecore.predicate.Predicate<? super T> where) { return transform(items, where, null, null, null); }
@Deprecated public static <T> List<T> transform(Iterable<T> items, com.massivecraft.massivecore.predicate.Predicate<? super T> where, Comparator<? super T> orderby) { return transform(items, where, orderby, null, null); }
@Deprecated public static <T> List<T> transform(Iterable<T> items, com.massivecraft.massivecore.predicate.Predicate<? super T> where, Comparator<? super T> orderby, Integer limit) { return transform(items, where, orderby, limit, null); }
@Deprecated public static <T> List<T> transform(Iterable<T> items, com.massivecraft.massivecore.predicate.Predicate<? super T> where, Integer limit) { return transform(items, where, null, limit, null); }
@Deprecated public static <T> List<T> transform(Iterable<T> items, com.massivecraft.massivecore.predicate.Predicate<? super T> where, Integer limit, Integer offset) { return transform(items, where, null, limit, offset); }
// -------------------------------------------- // // -------------------------------------------- //
// SIMPLE CONSTRUCTORS // SIMPLE CONSTRUCTORS
// -------------------------------------------- // // -------------------------------------------- //