All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.meeuw.json.grep.matching.ObjectHasKeyMatcher Maven / Gradle / Ivy

package org.meeuw.json.grep.matching;

import java.util.function.Predicate;

import org.meeuw.json.ParseEvent;
import org.meeuw.json.Path;
import org.meeuw.util.Predicates;

/**
 * @author Michiel Meeuwissen
 * @since ...
 */
public class ObjectHasKeyMatcher extends ObjectMatcher {

    private final String key;

    public ObjectHasKeyMatcher(String key) {
        this.key = key;
    }

    @Override
    protected boolean matches(ParseEvent event) {
        return event.getKeys().contains(key);
    }

    @Override
    public Predicate needsKeyCollection() {
        return Predicates.alwaysTrue();
    }

    @Override
    public Predicate needsObjectCollection() {
        return Predicates.alwaysFalse();
    }

	@Override
	public String toString() {
		return "contains " + key;
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy