
de.codecentric.mule.assertobjectequals.PatternBasedOptionsFactory Maven / Gradle / Ivy
package de.codecentric.mule.assertobjectequals;
import java.util.ArrayList;
import java.util.Collection;
import java.util.EnumSet;
public class PatternBasedOptionsFactory implements ObjectCompareOptionsFactory {
private EnumSet rootOptions;
private Collection patterns;
public PatternBasedOptionsFactory(EnumSet rootOptions, Collection patterns) {
this.rootOptions = EnumSet.copyOf(rootOptions);
this.patterns = new ArrayList<>(patterns);
}
@Override
public EnumSet createOptions(EnumSet inherited, Path path) {
for (PathPattern pp : patterns) {
if (pp.matches(path)) {
return EnumSet.copyOf(pp.getOptions());
}
}
return EnumSet.copyOf(inherited == null ? rootOptions : inherited);
}
public EnumSet getRootOptions() {
return EnumSet.copyOf(rootOptions);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy