/** * Build a {@link ConfigurationMetadataRepository} with the current state of this * builder. * @return this builder */ public ConfigurationMetadataRepository build() { SimpleConfigurationMetadataRepository result = new SimpleConfigurationMetadataRepository(); for (SimpleConfigurationMetadataRepository repository : this.repositories) { result.include(repository); } return result; }
private static SimpleConfigurationMetadataRepository create(final RawConfigurationMetadata metadata) { val repository = new SimpleConfigurationMetadataRepository(); repository.add(metadata.getSources()); for (val item : metadata.getItems()) { val source = getSource(metadata, item); repository.add(item, source); } val allProperties = repository.getAllProperties(); for (val hint : metadata.getHints()) { var property = allProperties.get(hint.getId()); if (property != null) { addValueHints(property, hint); } else { val id = hint.resolveId(); property = allProperties.get(id); if (property != null) { if (hint.isMapKeyHints()) { addMapHints(property, hint); } else { addValueHints(property, hint); } } } } return repository; }
private void updateConfigRepo() { logger.fine("Updating config metadata repo"); repo = new SimpleConfigurationMetadataRepository(); final List<FileObject> cfgMetaFiles = cpExec.findAllResources(METADATA_JSON); for (FileObject fo : cfgMetaFiles) { currRepo = builder.withJsonResource(fo.getInputStream()).build(); repo.include(currRepo); } catch (Exception ex) { Exceptions.printStackTrace(ex); cachedProperties = repo.getAllProperties();
/** * Add a {@link ConfigurationMetadataProperty} with the * {@link ConfigurationMetadataSource source} that defines it, if any. * @param property the property to add * @param source the source */ public void add(ConfigurationMetadataProperty property, ConfigurationMetadataSource source) { if (source != null) { putIfAbsent(source.getProperties(), property.getId(), property); } putIfAbsent(getGroup(source).getProperties(), property.getId(), property); }
/** * Merge the content of the specified repository to this repository. * @param repository the repository to include */ public void include(ConfigurationMetadataRepository repository) { for (ConfigurationMetadataGroup group : repository.getAllGroups().values()) { ConfigurationMetadataGroup existingGroup = this.allGroups.get(group.getId()); if (existingGroup == null) { this.allGroups.put(group.getId(), group); } else { // Merge properties group.getProperties().forEach((name, value) -> putIfAbsent( existingGroup.getProperties(), name, value)); // Merge sources group.getSources().forEach((name, value) -> putIfAbsent(existingGroup.getSources(), name, value)); } } }
private SimpleConfigurationMetadataRepository create( RawConfigurationMetadata metadata) { SimpleConfigurationMetadataRepository repository = new SimpleConfigurationMetadataRepository(); repository.add(metadata.getSources()); for (ConfigurationMetadataItem item : metadata.getItems()) { ConfigurationMetadataSource source = getSource(metadata, item); repository.add(item, source); } Map<String, ConfigurationMetadataProperty> allProperties = repository .getAllProperties(); for (ConfigurationMetadataHint hint : metadata.getHints()) { ConfigurationMetadataProperty property = allProperties.get(hint.getId()); if (property != null) { addValueHints(property, hint); } else { String id = hint.resolveId(); property = allProperties.get(id); if (property != null) { if (hint.isMapKeyHints()) { addMapHints(property, hint); } else { addValueHints(property, hint); } } } } return repository; }
/** * Register the specified {@link ConfigurationMetadataSource sources}. * @param sources the sources to add */ public void add(Collection<ConfigurationMetadataSource> sources) { for (ConfigurationMetadataSource source : sources) { String groupId = source.getGroupId(); ConfigurationMetadataGroup group = this.allGroups.get(groupId); if (group == null) { group = new ConfigurationMetadataGroup(groupId); this.allGroups.put(groupId, group); } String sourceType = source.getType(); if (sourceType != null) { putIfAbsent(group.getSources(), sourceType, source); } } }
/** * Build a {@link ConfigurationMetadataRepository} with the current state of this * builder. * * @return this builder */ public ConfigurationMetadataRepository build() { val result = new SimpleConfigurationMetadataRepository(); for (val repository : this.repositories) { result.include(repository); } return result; }