de.ppi.deepsampler.persistence.api.ComboMatcher Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of deepsampler-persistence Show documentation
Show all versions of deepsampler-persistence Show documentation
This module is the core of the persistence api in DeepSampler.
/*
* Copyright 2020 PPI AG (Hamburg, Germany)
* This program is made available under the terms of the MIT License.
*/
package de.ppi.deepsampler.persistence.api;
import de.ppi.deepsampler.core.model.ParameterMatcher;
/**
* Special matcher to apply a {@link ParameterMatcher} and a {@link PersistentMatcher} to a single argument when defining a sample.
*
* This class will basically behave exactly like the given {@link ParameterMatcher}, but additionally it will hold a {@link PersistentMatcher} to
* retrieve it later in the loading process of persistent samples.
*
* Never create {@link ComboMatcher} yourself! Always use {@link PersistentMatchers#combo(Object, PersistentMatcher)} for this.
*
* @param type to get matched in some sense
* @author Rico Schrage
*/
public class ComboMatcher implements ParameterMatcher {
private final PersistentMatcher persistentMatcher;
private final ParameterMatcher parameterMatcher;
/**
* Create a ComboMatcher with the parameterMatcher to be imitated and the persistentMatcher to hold for the later creating of a real matcher
* in the proces of loading persistent samples.
*
* @param parameterMatcher the {@link ParameterMatcher} to imitate
* @param persistentMatcher the {@link PersistentMatcher} to hold
*/
ComboMatcher(ParameterMatcher parameterMatcher, PersistentMatcher persistentMatcher) {
this.parameterMatcher = parameterMatcher;
this.persistentMatcher = persistentMatcher;
}
/**
* @return the hold {@link PersistentMatcher}
*/
public PersistentMatcher getPersistentMatcher() {
return persistentMatcher;
}
/**
* @return the imitated {@link ParameterMatcher}
*/
public ParameterMatcher getParameterMatcher() {
return parameterMatcher;
}
@Override
public boolean matches(T parameter) {
return parameterMatcher.matches(parameter);
}
}