mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2025-07-03 00:15:35 +00:00
create AndDistributorTemplate
This commit is contained in:
parent
6da8c72593
commit
f76ef93fe6
@ -0,0 +1,30 @@
|
|||||||
|
package com.dfsek.terra.addons.feature.distributor.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.structure.feature.Distributor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class AndDistributorTemplate implements ObjectTemplate<Distributor>, ValidatedConfigTemplate {
|
||||||
|
@Value("distributors")
|
||||||
|
private List<Distributor> distributors;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Distributor get() {
|
||||||
|
Distributor current = distributors.remove(0);
|
||||||
|
while(!distributors.isEmpty()) {
|
||||||
|
current = current.and(distributors.remove(0));
|
||||||
|
}
|
||||||
|
return current;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean validate() throws ValidationException {
|
||||||
|
if(distributors.isEmpty()) throw new ValidationException("AND Distributor must specify at least 1 distributor.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user