Java Code Examples for org.apache.commons.configuration2.Configuration#getProperty()
The following examples show how to use
org.apache.commons.configuration2.Configuration#getProperty() .
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: CommonsConfigurationLookupService.java From nifi with Apache License 2.0 | 6 votes |
@Override public Optional<String> lookup(final Map<String, Object> coordinates) throws LookupFailureException { if (coordinates == null) { return Optional.empty(); } final String key = coordinates.get(KEY).toString(); if (StringUtils.isBlank(key)) { return Optional.empty(); } final Configuration config = getConfiguration(); if (config != null) { final Object value = config.getProperty(key); if (value != null) { return Optional.of(String.valueOf(value)); } } return Optional.empty(); }
Example 2
Source File: IoRegistryHelper.java From tinkerpop with Apache License 2.0 | 5 votes |
public static List<IoRegistry> createRegistries(final Configuration configuration) { if (configuration.containsKey(IoRegistry.IO_REGISTRY)) { final Object property = configuration.getProperty(IoRegistry.IO_REGISTRY); if (property instanceof IoRegistry) return Collections.singletonList((IoRegistry) property); else if (property instanceof List) return createRegistries((List) property); else if (property instanceof String) return createRegistries(Arrays.asList(((String) property).split(","))); else throw new IllegalArgumentException("The provided registry object can not be resolved to an instance: " + property); } else return Collections.emptyList(); }
Example 3
Source File: TraversalVertexProgram.java From tinkerpop with Apache License 2.0 | 5 votes |
public static <R> TraverserSet<R> loadHaltedTraversers(final Configuration configuration) { if (!configuration.containsKey(HALTED_TRAVERSERS)) return new TraverserSet<>(); final Object object = configuration.getProperty(HALTED_TRAVERSERS) instanceof String ? VertexProgramHelper.deserialize(configuration, HALTED_TRAVERSERS) : configuration.getProperty(HALTED_TRAVERSERS); if (object instanceof Traverser.Admin) return new TraverserSet<>((Traverser.Admin<R>) object); else { final TraverserSet<R> traverserSet = new TraverserSet<>(); traverserSet.addAll((Collection) object); return traverserSet; } }
Example 4
Source File: ToyGraphInputRDD.java From tinkerpop with Apache License 2.0 | 5 votes |
@Override public JavaPairRDD<Object, VertexWritable> readGraphRDD(final Configuration configuration, final JavaSparkContext sparkContext) { KryoShimServiceLoader.applyConfiguration(TinkerGraph.open().configuration()); final List<VertexWritable> vertices; if (configuration.getString(Constants.GREMLIN_HADOOP_INPUT_LOCATION).contains("modern")) vertices = IteratorUtils.list(IteratorUtils.map(TinkerFactory.createModern().vertices(), VertexWritable::new)); else if (configuration.getString(Constants.GREMLIN_HADOOP_INPUT_LOCATION).contains("classic")) vertices = IteratorUtils.list(IteratorUtils.map(TinkerFactory.createClassic().vertices(), VertexWritable::new)); else if (configuration.getString(Constants.GREMLIN_HADOOP_INPUT_LOCATION).contains("crew")) vertices = IteratorUtils.list(IteratorUtils.map(TinkerFactory.createTheCrew().vertices(), VertexWritable::new)); else if (configuration.getString(Constants.GREMLIN_HADOOP_INPUT_LOCATION).contains("sink")) vertices = IteratorUtils.list(IteratorUtils.map(TinkerFactory.createKitchenSink().vertices(), VertexWritable::new)); else if (configuration.getString(Constants.GREMLIN_HADOOP_INPUT_LOCATION).contains("grateful")) { try { final Graph graph = TinkerGraph.open(); final GraphReader reader = GryoReader.build().mapper(graph.io(GryoIo.build()).mapper().create()).create(); try (final InputStream stream = GryoResourceAccess.class.getResourceAsStream("grateful-dead-v3d0.kryo")) { reader.readGraph(stream, graph); } vertices = IteratorUtils.list(IteratorUtils.map(graph.vertices(), VertexWritable::new)); } catch (final IOException e) { throw new IllegalStateException(e.getMessage(), e); } } else throw new IllegalArgumentException("No legal toy graph was provided to load: " + configuration.getProperty(Constants.GREMLIN_HADOOP_INPUT_LOCATION)); return sparkContext.parallelize(vertices).mapToPair(vertex -> new Tuple2<>(vertex.get().id(), vertex)); }
Example 5
Source File: ConfigurationDynaBean.java From commons-configuration with Apache License 2.0 | 5 votes |
@Override public Object get(final String name, final String key) { final Configuration subset = getConfiguration().subset(name); if (subset == null) { throw new IllegalArgumentException("Mapped property '" + name + "' does not exist."); } return subset.getProperty(key); }
Example 6
Source File: PureTraversal.java From tinkerpop with Apache License 2.0 | 4 votes |
public static <S, E> PureTraversal<S, E> loadState(final Configuration configuration, final String configurationKey, final Graph graph) { final Object configValue = configuration.getProperty(configurationKey); final PureTraversal<S, E> pureTraversal = (configValue instanceof String ? (PureTraversal<S, E>) VertexProgramHelper.deserialize(configuration, configurationKey) : ((PureTraversal<S, E>) configValue)); pureTraversal.pureTraversal.setGraph(graph); return pureTraversal; }
Example 7
Source File: ShortestPathVertexProgram.java From tinkerpop with Apache License 2.0 | 4 votes |
@Override public void loadState(final Graph graph, final Configuration configuration) { if (configuration.containsKey(SOURCE_VERTEX_FILTER)) this.sourceVertexFilterTraversal = PureTraversal.loadState(configuration, SOURCE_VERTEX_FILTER, graph); if (configuration.containsKey(TARGET_VERTEX_FILTER)) this.targetVertexFilterTraversal = PureTraversal.loadState(configuration, TARGET_VERTEX_FILTER, graph); if (configuration.containsKey(EDGE_TRAVERSAL)) this.edgeTraversal = PureTraversal.loadState(configuration, EDGE_TRAVERSAL, graph); if (configuration.containsKey(DISTANCE_TRAVERSAL)) this.distanceTraversal = PureTraversal.loadState(configuration, DISTANCE_TRAVERSAL, graph); if (configuration.containsKey(MAX_DISTANCE)) this.maxDistance = (Number) configuration.getProperty(MAX_DISTANCE); this.distanceEqualsNumberOfHops = this.distanceTraversal.equals(DEFAULT_DISTANCE_TRAVERSAL); this.includeEdges = configuration.getBoolean(INCLUDE_EDGES, false); this.standalone = !configuration.containsKey(VertexProgramStep.ROOT_TRAVERSAL); if (!this.standalone) { this.traversal = PureTraversal.loadState(configuration, VertexProgramStep.ROOT_TRAVERSAL, graph); final String programStepId = configuration.getString(ProgramVertexProgramStep.STEP_ID); for (final Step step : this.traversal.get().getSteps()) { if (step.getId().equals(programStepId)) { //noinspection unchecked this.programStep = step; break; } } } // restore halted traversers from the configuration and build an index for direct access this.haltedTraversers = TraversalVertexProgram.loadHaltedTraversers(configuration); this.haltedTraversersIndex = new IndexedTraverserSet<>(v -> v); for (final Traverser.Admin<Vertex> traverser : this.haltedTraversers) { this.haltedTraversersIndex.add(traverser.split()); } this.memoryComputeKeys.add(MemoryComputeKey.of(SHORTEST_PATHS, Operator.addAll, true, !standalone)); }