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

org.everit.json.schema.regexp.RE2JRegexpFactory Maven / Gradle / Ivy

Go to download

This is a fork of the implementation of the JSON Schema Core Draft v4 specification built with the org.json API which also supports internationalization

The newest version!
package org.everit.json.schema.regexp;

import java.util.Optional;

import com.google.re2j.Pattern;

class RE2JRegexp extends AbstractRegexp {

    private Pattern pattern;

    RE2JRegexp(String pattern) {
        super(pattern);
        this.pattern = Pattern.compile(pattern);
    }

    @Override public Optional patternMatchingFailure(String input) {
        if (pattern.matcher(input).find()) {
            return Optional.empty();
        } else {
            return Optional.of(new RegexpMatchingFailure());
        }
    }

}

public class RE2JRegexpFactory implements RegexpFactory {
    @Override public Regexp createHandler(String input) {
        return new RE2JRegexp(input);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy