Interface CMatter

  • All Implemented Interfaces:

    
    public interface CMatter
    
                        

    This interface's implementing types can be used as materials for CRecipe.

    Since:

    5.0.0

    • Constructor Detail

    • Method Detail

      • hasPredicates

         Boolean hasPredicates()

        returns this CMatter has some predicates or not.

        Returns:

        Boolean == !predicates.isNullOrEmpty()

      • predicatesResult

         Boolean predicatesResult(CMatterPredicate.Context ctx)

        Returns a merged result of all predicates run.

        // Default implementation on `CMatter#predicatesResult`
        fun predicatesResult(ctx: CMatterPredicate.Context): Boolean {
            return predicates?.all { p -> p.test(ctx) } ?: true
        }
        Parameters:
        ctx - Context of CMatterPredicate execution
        Returns:

        Boolean all or nothing.

      • firstFailedPredicate

         Pair<Integer, CMatterPredicate> firstFailedPredicate(CMatterPredicate.Context ctx)

        Returns the first CMatterPredicate that rejects ctx, or null when all of them pass.

        Evaluates predicates in order and stops at the first failure, exactly as predicatesResult does, so this can be used in its place when the caller needs to report which predicate failed rather than only whether one did. The returned index is the position within predicates and identifies a predicate that did not override CMatterPredicate.name.

        Parameters:
        ctx - Context of CMatterPredicate execution
        Returns:

        Pair The failing predicate's index paired with the predicate itself, or null when nothing failed

        Since:

        5.3.0

      • getAmount

         abstract Integer getAmount()

        Required item count. Ignored when anyAmount is true. Must be 1 or greater.

      • getAnyAmount

         abstract Boolean getAnyAmount()

        If true, any input amount ≥ 1 is accepted regardless of amount. If false, input must have at least amount items.

      • getPredicates

         abstract List<CMatterPredicate> getPredicates()

        List of additional CMatterPredicate checks that run during slot matching. null or empty means no additional conditions.

        Ordered, so an unnamed predicate can be reported by its index in diagnostic logs.