tech.ferus.util.config.transformer.SetTransformer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ConfigKeys Show documentation
Show all versions of ConfigKeys Show documentation
ConfigKeys is a simple wrapper for zml's Configurate, providing a more stream-lined way to access configuration on-the-fly.
The newest version!
package tech.ferus.util.config.transformer;
import com.google.common.collect.Sets;
import ninja.leaping.configurate.ConfigurationNode;
import java.util.Set;
/**
* Intended to transform convert a {@link ConfigurationNode} list
* into a set of whatever is specified.
*
* @param the type of set to convert to
*/
public class SetTransformer implements Transformer> {
@SuppressWarnings("unchecked")
@Override
public Set transform(final ConfigurationNode node) throws TransformerException {
if (!node.hasListChildren()) {
throw new TransformerException("Node isn't a list format and cannot be transformed.");
}
final Set collect = Sets.newHashSet();
try {
for (final ConfigurationNode element : node.getChildrenList()) {
collect.add((T) element.getValue());
}
} catch (final Exception e) {
throw new TransformerException(e);
}
return collect;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy