mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2025-07-02 16:05:29 +00:00
OrLocatorTemplate
This commit is contained in:
parent
12c068b252
commit
d6b36f4d3f
@ -0,0 +1,30 @@
|
||||
package com.dfsek.terra.addons.feature.locator.config;
|
||||
|
||||
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.api.config.meta.Meta;
|
||||
import com.dfsek.terra.api.structure.feature.Locator;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class OrLocatorTemplate implements ObjectTemplate<Locator>, ValidatedConfigTemplate {
|
||||
@Value("locators")
|
||||
private @Meta List<@Meta Locator> locators;
|
||||
|
||||
@Override
|
||||
public Locator get() {
|
||||
Locator current = locators.remove(0);
|
||||
while(!locators.isEmpty()) {
|
||||
current = current.or(locators.remove(0));
|
||||
}
|
||||
return current;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate() throws ValidationException {
|
||||
if(locators.isEmpty()) throw new ValidationException("AND Pattern must specify at least 1 pattern.");
|
||||
return true;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user