Skip to content

Commit

Permalink
Replace Guava Predicates with Java 8 Predicates.
Browse files Browse the repository at this point in the history
Signed-off-by: Gabriel Harris-Rouquette <[email protected]>
  • Loading branch information
gabizou committed Oct 4, 2015
1 parent 20bad1b commit 6a4f0ee
Show file tree
Hide file tree
Showing 29 changed files with 179 additions and 72 deletions.
3 changes: 2 additions & 1 deletion src/main/java/org/spongepowered/api/attribute/Attribute.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@
*/
package org.spongepowered.api.attribute;

import com.google.common.base.Predicate;
import org.spongepowered.api.CatalogType;
import org.spongepowered.api.data.DataHolder;
import org.spongepowered.api.util.annotation.CatalogedBy;

import java.util.function.Predicate;

/**
* Represents a type of attribute that can be applied to an
* {@link DataHolder}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@
*/
package org.spongepowered.api.attribute;

import com.google.common.base.Predicate;
import org.spongepowered.api.data.DataHolder;
import org.spongepowered.api.text.Text;

import java.util.function.Predicate;

/**
* A builder for plugins to create custom {@link Attribute}s.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@
*/
package org.spongepowered.api.attribute;

import com.google.common.base.Predicate;
import org.spongepowered.api.data.DataHolder;

import java.util.function.Predicate;

/**
* An enumeration of all attribute targets present in vanilla Minecraft.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@

package org.spongepowered.api.block.trait;

import com.google.common.base.Predicate;
import org.spongepowered.api.block.BlockState;
import org.spongepowered.api.block.BlockType;
import org.spongepowered.api.block.BlockTypes;

import java.util.Collection;
import java.util.function.Predicate;

/**
* Represents a possible trait in a {@link BlockType}s {@link BlockState}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

package org.spongepowered.api.block.trait;

import com.google.common.base.Predicate;
import java.util.function.Predicate;

/**
* Represents a type of {@link BlockTrait} that accepts {@link Integer} based
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
*/
package org.spongepowered.api.data.value.immutable;

import com.google.common.base.Predicate;
import org.spongepowered.api.attribute.Attribute;
import org.spongepowered.api.attribute.AttributeModifier;
import org.spongepowered.api.data.value.mutable.AttributeMapValue;

import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.function.Predicate;

/**
* A customized {@link ImmutableMapValue} specifically handling
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
*/
package org.spongepowered.api.data.value.immutable;

import com.google.common.base.Predicate;
import org.spongepowered.api.data.value.ValueContainer;
import org.spongepowered.api.data.value.mutable.CollectionValue;

import java.util.Collection;
import java.util.function.Function;
import java.util.function.Predicate;

/**
* A {@link ImmutableValue} type that handles a {@link Collection} of elements
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
*/
package org.spongepowered.api.data.value.immutable;

import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableCollection;
import com.google.common.collect.ImmutableSet;
import org.spongepowered.api.data.value.mutable.MapValue;

import java.util.Map;
import java.util.Map.Entry;
import java.util.function.Function;
import java.util.function.Predicate;

/**
* Represents a specialized type of {@link ImmutableValue} that is different
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
*/
package org.spongepowered.api.data.value.immutable;

import com.google.common.base.Predicate;
import org.spongepowered.api.data.meta.PatternLayer;
import org.spongepowered.api.data.type.BannerPatternShape;
import org.spongepowered.api.data.type.DyeColor;
import org.spongepowered.api.data.value.mutable.PatternListValue;

import java.util.List;
import java.util.function.Predicate;

public interface ImmutablePatternListValue extends ImmutableListValue<PatternLayer> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
*/
package org.spongepowered.api.data.value.mutable;

import com.google.common.base.Predicate;
import org.spongepowered.api.attribute.Attribute;
import org.spongepowered.api.attribute.AttributeModifier;
import org.spongepowered.api.data.value.immutable.ImmutableAttributeMapValue;

import java.util.List;
import java.util.Map;
import java.util.function.Predicate;

/**
* A customized {@link MapValue} that handles the intricacies of
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
*/
package org.spongepowered.api.data.value.mutable;

import com.google.common.base.Predicate;
import org.spongepowered.api.data.value.immutable.ImmutableCollectionValue;

import java.util.Collection;
import java.util.function.Function;
import java.util.function.Predicate;

/**
* Represents a {@link Value} that is backed by a {@link Collection} of
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
*/
package org.spongepowered.api.data.value.mutable;

import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableCollection;
import com.google.common.collect.ImmutableSet;
import org.spongepowered.api.data.value.immutable.ImmutableMapValue;

import java.util.Map;
import java.util.Map.Entry;
import java.util.function.Function;
import java.util.function.Predicate;

/**
* Represents a specialized type of {@link Value} that is different from
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
*/
package org.spongepowered.api.data.value.mutable;

import com.google.common.base.Predicate;
import org.spongepowered.api.data.meta.PatternLayer;
import org.spongepowered.api.data.type.BannerPatternShape;
import org.spongepowered.api.data.type.DyeColor;
import org.spongepowered.api.data.value.immutable.ImmutablePatternListValue;

import java.util.List;
import java.util.function.Function;
import java.util.function.Predicate;

/**
* Represents a customized {@link ListValue} handling {@link PatternLayer}s.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
*/
package org.spongepowered.api.event.block;

import com.google.common.base.Predicate;
import org.spongepowered.api.block.BlockState;
import org.spongepowered.api.block.BlockTransaction;
import org.spongepowered.api.event.Cancellable;
Expand All @@ -36,6 +35,7 @@
import org.spongepowered.api.world.World;

import java.util.List;
import java.util.function.Predicate;

/**
* Base event for when {@link BlockState}s at {@link Location<World>}s are being
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
*/
package org.spongepowered.api.event.block;

import com.google.common.base.Predicate;
import org.spongepowered.api.block.BlockState;
import org.spongepowered.api.event.Cancellable;
import org.spongepowered.api.event.entity.ChangeEntityExperienceEvent;
import org.spongepowered.api.item.inventory.ItemStack;
import org.spongepowered.api.world.Location;

import java.util.Collection;
import java.util.function.Predicate;

/**
* Base event for when a target {@link BlockState} at a {@link Location} is
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

package org.spongepowered.api.event.block;

import com.google.common.base.Predicate;
import org.spongepowered.api.block.BlockSnapshot;
import org.spongepowered.api.block.BlockState;
import org.spongepowered.api.event.Cancellable;
Expand All @@ -36,6 +35,7 @@
import org.spongepowered.api.world.World;

import java.util.Map;
import java.util.function.Predicate;

/**
* Called when a block at a {@link Location} triggers an update to one or more
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
*/
package org.spongepowered.api.event.entity;

import com.google.common.base.Predicate;
import org.spongepowered.api.entity.Entity;
import org.spongepowered.api.entity.EntitySnapshot;
import org.spongepowered.api.event.Cancellable;
Expand All @@ -38,6 +37,7 @@
import org.spongepowered.api.world.explosion.Explosion;

import java.util.List;
import java.util.function.Predicate;

/**
* An event that affects multiple {@link Entity} instances as a bulk action.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
*/
package org.spongepowered.api.event.entity.item;

import com.google.common.base.Predicate;
import org.spongepowered.api.entity.Entity;
import org.spongepowered.api.entity.Item;
import org.spongepowered.api.event.entity.AffectEntityEvent;
import org.spongepowered.api.world.Location;
import org.spongepowered.api.world.World;

import java.util.List;
import java.util.function.Predicate;

public interface AffectItemEvent extends AffectEntityEvent {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
*/
package org.spongepowered.api.event.inventory;

import com.google.common.base.Predicate;
import org.spongepowered.api.event.Cancellable;
import org.spongepowered.api.event.cause.CauseTracked;
import org.spongepowered.api.item.inventory.Inventory;
import org.spongepowered.api.item.inventory.ItemStack;
import org.spongepowered.api.item.inventory.ItemStackTransaction;

import java.util.List;
import java.util.function.Predicate;

/**
* Fired when {@link ItemStack}s are generated into a {@link Inventory}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
*/
package org.spongepowered.api.event.inventory;

import com.google.common.base.Predicate;
import org.spongepowered.api.entity.Item;
import org.spongepowered.api.event.Cancellable;
import org.spongepowered.api.event.GameEvent;
Expand All @@ -35,6 +34,7 @@
import org.spongepowered.api.item.inventory.ItemStackTransaction;

import java.util.List;
import java.util.function.Predicate;

/**
* Handles when any {@link ItemStack}(s) is/are about to be "dropped" onto
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@
*/
package org.spongepowered.api.service;

import com.google.common.base.Predicate;

import java.util.Optional;
import java.util.function.Predicate;

/**
* A reference to a service that may or may not be currently registered, but will be updated if a registration does happen.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

import static com.google.common.base.Preconditions.checkNotNull;

import com.google.common.base.Predicate;
import com.google.common.collect.MapMaker;
import org.spongepowered.api.plugin.PluginContainer;
import org.spongepowered.api.plugin.PluginManager;
Expand All @@ -38,6 +37,7 @@
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.function.Predicate;

import javax.annotation.Nullable;
import javax.inject.Inject;
Expand Down Expand Up @@ -175,7 +175,7 @@ public void executeWhenPresent(Predicate<T> run) {
if (!this.service.isPresent()) {
this.actionsOnPresent.add(run);
} else {
run.apply(this.service.get());
run.test(this.service.get());
}
}

Expand All @@ -188,7 +188,7 @@ public void registered(T service) {
this.waitLock.unlock();
}
for (Predicate<T> func : this.actionsOnPresent) {
func.apply(service);
func.test(service);
}
this.actionsOnPresent.clear();

Expand Down
Loading

0 comments on commit 6a4f0ee

Please sign in to comment.