Class EntityPredicate

java.lang.Object
com.github.darksoulq.abyssallib.world.entity.EntityPredicate
All Implemented Interfaces:
Predicate<SavedEntity>

public class EntityPredicate extends Object implements Predicate<SavedEntity>
A predicate used to evaluate and filter SavedEntity instances based on their identity and raw serialized data. This class allows for complex conditional checks against an entity's JSON-like data structure, identity keys, and nested predicate logic.
  • Field Details

    • CODEC

      public static final Codec<EntityPredicate> CODEC
      The primary codec used to serialize and deserialize entire EntityPredicate instances. Supports resolving registered predicates by their String ID or parsing full nested objects.
  • Constructor Details

    • EntityPredicate

      public EntityPredicate(net.kyori.adventure.key.Key id, List<Condition<Map.Entry<String, com.fasterxml.jackson.databind.JsonNode>>> data, List<Condition<EntityPredicate>> predicates)
      Constructs a new EntityPredicate with the specified conditional rules.
      Parameters:
      id - The identity Key that must match (nullable for any entity).
      data - The list of specific value-matching JSON data conditions.
      predicates - The list of nested predicate conditions.
  • Method Details

    • builder

      public static EntityPredicate.Builder builder()
      Creates a new fluent builder instance for constructing an EntityPredicate.
      Returns:
      A new EntityPredicate.Builder instance.
    • equals

      public boolean equals(Object o)
      Compares this predicate against another object for logical equivalence.
      Overrides:
      equals in class Object
      Parameters:
      o - The object to compare.
      Returns:
      True if the object is an identical EntityPredicate.
    • hashCode

      public int hashCode()
      Generates a hash code based on the predicate's underlying conditions.
      Overrides:
      hashCode in class Object
      Returns:
      The integer hash code.
    • test

      public boolean test(SavedEntity info)
      Evaluates a SavedEntity against all configured conditions within this predicate.
      Specified by:
      test in interface Predicate<SavedEntity>
      Parameters:
      info - The SavedEntity to test.
      Returns:
      True if the entity satisfies all identity, data, and nested rules; false otherwise.