mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-06-17 14:21:08 +00:00
create AndPatternTemplate
This commit is contained in:
+29
@@ -0,0 +1,29 @@
|
|||||||
|
package com.dfsek.terra.addons.feature.locator.config.pattern;
|
||||||
|
|
||||||
|
import com.dfsek.tectonic.annotations.Value;
|
||||||
|
import com.dfsek.tectonic.config.ValidatedConfigTemplate;
|
||||||
|
import com.dfsek.tectonic.exception.ValidationException;
|
||||||
|
import com.dfsek.tectonic.loading.object.ObjectTemplate;
|
||||||
|
import com.dfsek.terra.addons.feature.locator.patterns.Pattern;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class AndPatternTemplate implements ObjectTemplate<Pattern>, ValidatedConfigTemplate {
|
||||||
|
@Value("patterns")
|
||||||
|
private List<Pattern> patterns;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Pattern get() {
|
||||||
|
Pattern current = patterns.remove(0);
|
||||||
|
while(!patterns.isEmpty()) {
|
||||||
|
current = current.and(patterns.remove(0));
|
||||||
|
}
|
||||||
|
return current;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean validate() throws ValidationException {
|
||||||
|
if(patterns.isEmpty()) throw new ValidationException("AND Pattern must specify at least 1 pattern.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user