Java Code Examples for org.apache.commons.configuration2.ConfigurationUtils#copy()

The following examples show how to use org.apache.commons.configuration2.ConfigurationUtils#copy() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConnectedComponentVertexProgram.java    From tinkerpop with Apache License 2.0 6 votes vote down vote up
@Override
public void loadState(final Graph graph, final Configuration config) {
    configuration = new BaseConfiguration();
    if (config != null) {
        ConfigurationUtils.copy(config, configuration);
    }

    if (configuration.containsKey(EDGE_TRAVERSAL)) {
        this.edgeTraversal = PureTraversal.loadState(configuration, EDGE_TRAVERSAL, graph);
        this.scope = MessageScope.Local.of(() -> this.edgeTraversal.get().clone());
    }

    scopes = new HashSet<>(Collections.singletonList(scope));

    this.property = configuration.getString(PROPERTY, COMPONENT);

    this.haltedTraversers = TraversalVertexProgram.loadHaltedTraversers(configuration);
    this.haltedTraversersIndex = new IndexedTraverserSet<>(v -> v);
    for (final Traverser.Admin<Vertex> traverser : this.haltedTraversers) {
        this.haltedTraversersIndex.add(traverser.split());
    }
}
 
Example 2
Source File: GraphFactory.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
private static org.apache.commons.configuration2.Configuration getConfiguration(final File configurationFile) {
    if (!configurationFile.isFile())
        throw new IllegalArgumentException(String.format("The location configuration must resolve to a file and [%s] does not", configurationFile));

    try {
        final String fileName = configurationFile.getName();
        final String fileExtension = fileName.substring(fileName.lastIndexOf('.') + 1);

        final Configuration conf;
        final Configurations configs = new Configurations();

        switch (fileExtension) {
            case "yml":
            case "yaml":
                final Parameters params = new Parameters();
                final FileBasedConfigurationBuilder<FileBasedConfiguration> builder =
                        new FileBasedConfigurationBuilder<FileBasedConfiguration>(YAMLConfiguration.class).
                                configure(params.fileBased().setFile(configurationFile));

                final org.apache.commons.configuration2.Configuration copy = new org.apache.commons.configuration2.BaseConfiguration();
                ConfigurationUtils.copy(builder.configure(params.fileBased().setFile(configurationFile)).getConfiguration(), copy);
                conf = copy;
                break;
            case "xml":
                conf = configs.xml(configurationFile);
                break;
            default:
                conf = configs.properties(configurationFile);
        }
        return conf;
    } catch (ConfigurationException e) {
        throw new IllegalArgumentException(String.format("Could not load configuration at: %s", configurationFile), e);
    }
}
 
Example 3
Source File: ConnectedComponentVertexProgram.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Override
public void storeState(final Configuration config) {
    VertexProgram.super.storeState(config);
    if (configuration != null) {
        ConfigurationUtils.copy(configuration, config);
    }
}
 
Example 4
Source File: GraphComputerTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Override
public void storeState(final Configuration config) {
    VertexProgram.super.storeState(config);
    if (configuration != null) {
        ConfigurationUtils.copy(configuration, config);
    }
}
 
Example 5
Source File: GraphComputerTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Override
public void loadState(final Graph graph, final Configuration config) {
    configuration = new BaseConfiguration();
    if (config != null) {
        ConfigurationUtils.copy(config, configuration);
    }
    propertyKey = configuration.getString(PROPERTY_CFG_KEY);
    traverserRequirements = configuration.getBoolean(USE_TRAVERSER_REQUIREMENTS_CFG_KEY, true)
            ? Collections.singleton(TraverserRequirement.PATH) : Collections.emptySet();
    elementComputeKeys.add(VertexComputeKey.of(propertyKey, false));
}
 
Example 6
Source File: IncrementalDataPlaneSettings.java    From batfish with Apache License 2.0 2 votes vote down vote up
/**
 * Create new settings, initialize with defaults, but also copy over settings from {@code
 * configSource}
 *
 * @param configSource the configuration options to override the defaults
 */
public IncrementalDataPlaneSettings(ImmutableConfiguration configSource) {
  this();
  ConfigurationUtils.copy(configSource, _config);
}