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

com.github.dakusui.lisj.pred.Matches Maven / Gradle / Ivy

There is a newer version: 0.8.17
Show newest version
package com.github.dakusui.lisj.pred;

import static com.github.dakusui.lisj.Basic.get;

import com.github.dakusui.jcunit.core.Utils;
import com.github.dakusui.lisj.Context;
import com.github.dakusui.lisj.FormResult;

public class Matches extends BinomialPredicate {
	/**
	 * Serial version UID.
	 */
	private static final long serialVersionUID = 7402316173263455615L;

	@Override
	protected Object checkParams(Object params) {
		super.checkParams(params);
		Utils.checknull(get(params, 0));
		Utils.checknull(get(params, 1));
		return params;
	}
	
	@Override
	protected FormResult evaluateLast(Context context, Object[] evaluatedParams, FormResult lastResult) {
		FormResult ret = lastResult;
		
		String regex = evaluatedParams[1].toString();
		String value = evaluatedParams[0].toString();

		ret.value(value.matches(regex));
		return ret;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy