Java Code Examples for java.util.Collections#emptyMap()

The following examples show how to use java.util.Collections#emptyMap() . 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: AbstractKubernetesConfigSourceUtil.java    From quarkus with Apache License 2.0 6 votes vote down vote up
private static CategorizedConfigSourceData categorize(Map<String, String> data) {
    if ((data == null) || data.isEmpty()) {
        return new CategorizedConfigSourceData(Collections.emptyMap(), Collections.emptyList());
    }

    Map<String, String> literalData = new HashMap<>();
    List<Map.Entry<String, String>> fileData = new ArrayList<>();
    for (Map.Entry<String, String> entry : data.entrySet()) {
        String key = entry.getKey();
        if (key.endsWith(".yml") || key.endsWith(".yaml") || key.endsWith(".properties")) {
            fileData.add(entry);
        } else {
            literalData.put(key, entry.getValue());
        }
    }

    return new CategorizedConfigSourceData(literalData, fileData);
}
 
Example 2
Source File: ReflectionTableParser.java    From openemm with GNU Affero General Public License v3.0 6 votes vote down vote up
private Map<String, String> getRowColumnsFromObjectMethods(Object object) {
    Class<?> clazz = object.getClass();
    if (Objects.isNull(AnnotationUtils.findAnnotation(clazz, textTableClass))) {
        return Collections.emptyMap();
    }

    Map<String, String> rowColumns = new LinkedHashMap<>();
    for (Method method : clazz.getDeclaredMethods()) {
        TextColumn textColumn = AnnotationUtils.findAnnotation(method, textColumnClass);
        if (Objects.nonNull(textColumn) && (method.getParameterCount() == 0)) {
            String columnKey = StringUtils.defaultIfEmpty(textColumn.key(), method.getName());
            rowColumns.put(columnKey, getColumnValueFromMethod(method, object));
        }
    }

    return rowColumns;
}
 
Example 3
Source File: ClassMap.java    From commons-jexl with Apache License 2.0 6 votes vote down vote up
/**
 * Standard constructor.
 *
 * @param aClass the class to deconstruct.
 * @param permissions the permissions to apply during introspection
 * @param log    the logger.
 */
@SuppressWarnings("LeakingThisInConstructor")
ClassMap(Class<?> aClass, Permissions permissions, Log log) {
    // eagerly cache methods
    create(this, permissions, aClass, log);
    // eagerly cache public fields
    Field[] fields = aClass.getFields();
    if (fields.length > 0) {
        Map<String, Field> cache = new HashMap<String, Field>();
        for (Field field : fields) {
            if (permissions.allow(field)) {
                cache.put(field.getName(), field);
            }
        }
        fieldCache = cache;
    } else {
        fieldCache = Collections.emptyMap();
    }
}
 
Example 4
Source File: Responsibility.java    From rice with Educational Community License v2.0 5 votes vote down vote up
/**
 * A constructor using the Builder.
 *
 * @param builder
 */
private Responsibility(Builder builder) {
	this.id = builder.getId();
       this.namespaceCode = builder.getNamespaceCode();
       this.name = builder.getName();
       this.description = builder.getDescription();
       this.template = builder.getTemplate() != null ? builder.getTemplate().build() : null;
       this.attributes = builder.getAttributes() != null ? builder.getAttributes() : Collections.<String, String>emptyMap();
       this.active = builder.isActive();
       this.versionNumber = builder.getVersionNumber();
       this.objectId = builder.getObjectId();
}
 
Example 5
Source File: PomReader.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
private static Map<String, String> getProperties(final Element parent) {
    final Element propsEl = getFirstChildElement(parent, PROPERTIES);
    if (propsEl == null) {
        return Collections.emptyMap();
    }
    propsEl.normalize();
    final Map<String, String> props = new HashMap<>();
    for (final Element prop : getAllChilds(propsEl)) {
        props.put(prop.getNodeName(), getTextContent(prop));
    }
    return props;
}
 
Example 6
Source File: JsonWebKeys.java    From cxf with Apache License 2.0 5 votes vote down vote up
public Map<String, JsonWebKey> getKeyIdMap() {
    List<JsonWebKey> keys = getKeys();
    if (keys == null) {
        return Collections.emptyMap();
    }
    Map<String, JsonWebKey> map = new LinkedHashMap<>();
    for (JsonWebKey key : keys) {
        String kid = key.getKeyId();
        if (kid != null) {
            map.put(kid, key);
        }
    }
    return map;
}
 
Example 7
Source File: TreeModels.java    From ontopia with Apache License 2.0 5 votes vote down vote up
public static TreeModel createTopicTypesTreeModel(TopicMap tm, boolean isAnnotationEnabled, boolean isAdminEnabled) {
  StringBuilder sb = new StringBuilder(); 
  sb.append("using on for i\"http://psi.ontopia.net/ontology/\" ");
  sb.append("using xtm for i\"http://www.topicmaps.org/xtm/1.0/core.xtm#\" ");
  sb.append("select $P, $C from ");
  if (isAnnotationEnabled)
    sb.append("{ instance-of($C, on:ontology-type) | $C = on:topic-map, topic($C) | ");
  sb.append("instance-of($C, on:topic-type), ");
  if (!isAdminEnabled)
    sb.append("not(direct-instance-of($C, on:system-topic)), ");
  sb.append("{ xtm:superclass-subclass($C : xtm:subclass, $P : xtm:superclass), instance-of($P, on:topic-type)");
  if (!isAdminEnabled)
    sb.append(", not(direct-instance-of($P, on:system-topic))");
  sb.append(" }");    
  if (isAnnotationEnabled)
    sb.append("}");
  sb.append(" order by $P, $C?");
  
  final String topicMapId = tm.getId();
  Map<String,?> params = Collections.emptyMap();
  return new QueryTreeModel(tm, sb.toString(), params) {
    @Override
    protected DefaultMutableTreeNode createTreeNode(Object o) {
      return new DefaultMutableTreeNode(new TopicNode(topicMapId, ((TopicIF)o).getObjectId()));
    }
  };
}
 
Example 8
Source File: RiftService.java    From aion-germany with GNU General Public License v3.0 5 votes vote down vote up
public void initRiftLocations() {
	if (CustomConfig.RIFT_ENABLED) {
		locations = DataManager.RIFT_DATA.getRiftLocations();
		log.info("[RiftService] Loaded " + locations.size() + " rift locations");
	}
	else {
		locations = Collections.emptyMap();
	}
}
 
Example 9
Source File: TaskControllerTests.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
@Before
public void setupMockMVC() {
	this.mockMvc = MockMvcBuilders.webAppContextSetup(wac)
			.defaultRequest(get("/").accept(MediaType.APPLICATION_JSON)).build();

	launcherRepository.save(new Launcher("default", "local", taskLauncher));
	when(taskLauncher.launch(any(AppDeploymentRequest.class))).thenReturn("testID");


	Map<String, String> deploymentProperties = new HashMap<>();
	deploymentProperties.put("app.test.key1", "value1");
	TaskManifest taskManifest = new TaskManifest();
	AppDeploymentRequest request = new AppDeploymentRequest(new AppDefinition("test", Collections.emptyMap()), new FileSystemResource(""), deploymentProperties, null);
	taskManifest.setTaskDeploymentRequest(request);
	taskManifest.setPlatformName("test");

	final TaskExecution taskExecutionRunning = this.taskExecutionCreationService.createTaskExecution("myTask");
	taskExecutionRunning.setStartTime(new Date());
	when(taskExplorer.getLatestTaskExecutionForTaskName("myTask")).thenReturn(taskExecutionRunning);
	when(taskExplorer.getTaskExecution(taskExecutionRunning.getExecutionId())).thenReturn(taskExecutionRunning);
	this.dataflowTaskExecutionMetadataDao.save(taskExecutionRunning, taskManifest);

	final TaskExecution taskExecutionComplete = this.taskExecutionCreationService.createTaskExecution("myTask2");
	taskExecutionComplete.setTaskName("myTask2");
	taskExecutionComplete.setStartTime(new Date());
	taskExecutionComplete.setEndTime(new Date());
	taskExecutionComplete.setExitCode(0);
	when(taskExplorer.getLatestTaskExecutionForTaskName("myTask2")).thenReturn(taskExecutionComplete);
	when(taskExplorer.getTaskExecution(taskExecutionComplete.getExecutionId())).thenReturn(taskExecutionComplete);
	when(taskExplorer.getLatestTaskExecutionsByTaskNames(any()))
			.thenReturn(Arrays.asList(taskExecutionRunning, taskExecutionComplete));
	this.dataflowTaskExecutionMetadataDao.save(taskExecutionComplete, taskManifest);
}
 
Example 10
Source File: ArrayNotificationBuffer.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static NotificationBuffer getNotificationBuffer(
        MBeanServer mbs, Map<String, ?> env) {

    if (env == null)
        env = Collections.emptyMap();

    //Find out queue size
    int queueSize = EnvHelp.getNotifBufferSize(env);

    ArrayNotificationBuffer buf;
    boolean create;
    NotificationBuffer sharer;
    synchronized (globalLock) {
        buf = mbsToBuffer.get(mbs);
        create = (buf == null);
        if (create) {
            buf = new ArrayNotificationBuffer(mbs, queueSize);
            mbsToBuffer.put(mbs, buf);
        }
        sharer = buf.new ShareBuffer(queueSize);
    }
    /* We avoid holding any locks while calling createListeners.
     * This prevents possible deadlocks involving user code, but
     * does mean that a second ConnectorServer created and started
     * in this window will return before all the listeners are ready,
     * which could lead to surprising behaviour.  The alternative
     * would be to block the second ConnectorServer until the first
     * one has finished adding all the listeners, but that would then
     * be subject to deadlock.
     */
    if (create)
        buf.createListeners();
    return sharer;
}
 
Example 11
Source File: CDOMObject.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Retrieve the map of keys and values for the MapKey.
 * 
 * @param mapKey The MapKey we are retrieving
 * @return The map of keys and values.
 */
public final <K, V> Map<K, V> getMapFor(MapKey<K, V> mapKey)
{
	// The javadoc for getMapFor() says that it returns null, but the implementation does NOT
	// This caused an NPE in AspectToken.parseNonEmptyToken because it assumed a non-null map
	return mapChar == null ? Collections.emptyMap() : mapChar.getMapFor(mapKey);
}
 
Example 12
Source File: BinaryMetadata.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @return Name to ordinal mapping.
 */
public Map<String, Integer> enumMap() {
    if (nameToOrdinal == null)
        return Collections.emptyMap();

    return nameToOrdinal;
}
 
Example 13
Source File: MultiViewModel.java    From netbeans with Apache License 2.0 4 votes vote down vote up
MultiViewModel(MultiViewDescription[] descs, MultiViewDescription defaultDescr, 
               MultiViewModel.ActionRequestObserverFactory factory) {
    this(descs, defaultDescr, factory, Collections.<MultiViewDescription, MultiViewElement>emptyMap());
}
 
Example 14
Source File: DefaultPropertyFilterTest.java    From jasypt-spring-boot with MIT License 4 votes vote down vote up
@Test
public void shouldInclude_withExclusions_source_regex() {
    DefaultPropertyFilter filter = new DefaultPropertyFilter(null, Collections.singletonList("config.*"), null, null);
    MapPropertySource source = new MapPropertySource("applicationConfig", Collections.emptyMap());
    assertTrue(filter.shouldInclude(source, "some.property"));
}
 
Example 15
Source File: StorageLayer.java    From linstor-server with GNU General Public License v3.0 4 votes vote down vote up
@Override
public LayerProcessResult process(
    AbsRscLayerObject<Resource> rscLayerData,
    List<Snapshot> snapshotList,
    ApiCallRcImpl apiCallRc
)
    throws StorageException, ResourceException, VolumeException, AccessDeniedException, DatabaseException
{
    Map<DeviceProvider, List<VlmProviderObject<Resource>>> groupedVolumes =
        rscLayerData == null ? // == null when processing unprocessed snapshots
            Collections.emptyMap() :
            rscLayerData.streamVlmLayerObjects().collect(Collectors.groupingBy(this::getDevProviderByVlmObj));

    Map<DeviceProvider, List<VlmProviderObject<Snapshot>>> groupedSnapshotVolumes = snapshotList.stream()
        .flatMap(
            snap -> LayerRscUtils.getRscDataByProvider(
                AccessUtils.execPrivileged(() -> snap.getLayerData(storDriverAccCtx)), DeviceLayerKind.STORAGE
            ).stream()
        )
        .flatMap(snapData -> snapData.getVlmLayerObjects().values().stream())
        .collect(Collectors.groupingBy(this::getDevProviderByVlmObj));

    Set<DeviceProvider> deviceProviders = new HashSet<>();
    deviceProviders.addAll(
        groupedVolumes.entrySet().stream()
            .filter(entry -> !entry.getValue().isEmpty())
            .map(entry -> entry.getKey())
            .collect(Collectors.toSet())
    );
    deviceProviders.addAll(
        groupedSnapshotVolumes.entrySet().stream()
            .filter(entry -> !entry.getValue().isEmpty())
            .map(entry -> entry.getKey())
            .collect(Collectors.toSet())
    );

    for (DeviceProvider devProvider : deviceProviders)
    {
        List<VlmProviderObject<Resource>> vlmDataList = groupedVolumes.get(devProvider);
        List<VlmProviderObject<Snapshot>> snapVlmList = groupedSnapshotVolumes.get(devProvider);

        if (vlmDataList == null)
        {
            vlmDataList = Collections.emptyList();
        }
        if (snapVlmList == null)
        {
            snapVlmList = Collections.emptyList();
        }

        /*
         * Issue:
         * We might be in a path where we should take a snapshot of a DRBD resource.
         * If this DRBD resource has external meta-data, we have the following problem:
         * We are on one of two scenarios (might be more if combined with other layers):
         * 1) we are in the ""-path (data)
         * 2) we are in the ".meta"-path (meta-data)
         * In whichever case we are, we also have the order to take a snapshot.
         * The current snapVlmList will contain both, "" and ".meta" snapLayerData for both
         * cases.
         * That means that in the first case we only give the DeviceProvider the rscData of
         * "", but the order to create snapshot of "" AND ".meta". The second case obviously
         * also has a similar issue.
         *
         * As a first approach we filter here those snapLayerData which have a corresponding
         * rscLayerData. This solves the above mentioned issue
         *
         * However, this alone is not good enough, because i.e. deleting a snapshot
         * does not require any rscLayerData, which means the filtering from the mentioned
         * approach will filter all snapLayerData which prevents us from deleting
         * snapshots ever again.
         *
         * Therefore we add an exception. If the list of rscLayerData is empty, we do not
         * filter anything, as those operations *should* only cause resource-independent
         * operations, which are fine for all "*"-paths
         */

        snapVlmList = filterSnapVlms(vlmDataList, snapVlmList);

        devProvider.process(vlmDataList, snapVlmList, apiCallRc);

        for (VlmProviderObject<Resource> vlmData : vlmDataList)
        {
            if (
                vlmData.exists() &&
                ((Volume) vlmData.getVolume()).getFlags().isSet(storDriverAccCtx, Volume.Flags.DELETE)
            )
            {
                throw new ImplementationError(
                    devProvider.getClass().getSimpleName() + " did not delete the volume " + vlmData
                );
            }
        }
    }

    return LayerProcessResult.SUCCESS;
}
 
Example 16
Source File: SessionFactoryOptionsBuilder.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Map<String, SQLFunction> getCustomSqlFunctionMap() {
	return sqlFunctions == null ? Collections.emptyMap() : sqlFunctions;
}
 
Example 17
Source File: RequestCreator.java    From wasp with Apache License 2.0 4 votes vote down vote up
Map<String, String> getFieldParams() {
  return fieldParams != null ? fieldParams : Collections.<String, String>emptyMap();
}
 
Example 18
Source File: TemplateResourceProcessor.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Creates a {@link VirtualFolderDefinition} that represents the structure
 * of the virtual folder.
 * 
 * @param context The context in which the virtualization process takes
 *            place.
 * @param result A map containing the details that define the virtual
 *            entries.
 * @return a {@link VirtualFolderDefinition} reference.
 * @throws ResourceProcessingError
 */
protected VirtualFolderDefinition asVirtualStructure(VirtualContext context, Map<String, Object> result)
            throws ResourceProcessingError
{
    try
    {
        Map<String, Object> mapResult = result;

        VirtualFolderDefinition virtualStructure = new VirtualFolderDefinition();

        String id = (String) mapResult.get(ID_KEY);
        virtualStructure.setId(id);

        String name = (String) mapResult.get(NAME_KEY);
        virtualStructure.setName(name);

        String description = (String) mapResult.get(DESCRIPTION_KEY);
        virtualStructure.setDescription(description);

        @SuppressWarnings("unchecked")
        VirtualQuery virtualQuery = asVirtualQuery(context,
                                                   (Map<String, Object>) mapResult.get(SEARCH_KEY));
        virtualStructure.setQuery(virtualQuery);

        FilingRule filingRule = asFilingRule(context,
                                             mapResult.get(FILING_KEY));
        if (filingRule == null)
        {
            filingRule = new NullFilingRule(context.getActualEnviroment());
        }
        virtualStructure.setFilingRule(filingRule);

        @SuppressWarnings("unchecked")
        Map<String, String> properties = (Map<String, String>) mapResult.get(PROPERTIES_KEY);
        if (properties == null)
        {
            properties = Collections.emptyMap();
        }

        virtualStructure.setProperties(properties);

        @SuppressWarnings("unchecked")
        List<Map<String, Object>> nodes = (List<Map<String, Object>>) mapResult.get(NODES_KEY);

        if (nodes != null)
        {
            for (Map<String, Object> node : nodes)
            {
                VirtualFolderDefinition child = asVirtualStructure(context,
                                                                   node);
                virtualStructure.addChild(child);
            }
        }

        return virtualStructure;
    }
    catch (ClassCastException e)
    {
        throw new ResourceProcessingError(e);
    }
}
 
Example 19
Source File: MeasurementSchema.java    From incubator-iotdb with Apache License 2.0 4 votes vote down vote up
public MeasurementSchema(String measurementId, TSDataType tsDataType) {
  this(measurementId, tsDataType,
      TSEncoding.valueOf(TSFileDescriptor.getInstance().getConfig().getValueEncoder()),
      TSFileDescriptor.getInstance().getConfig().getCompressor(),
      Collections.emptyMap());
}
 
Example 20
Source File: TableFormatFactoryBase.java    From flink with Apache License 2.0 2 votes vote down vote up
/**
 * Format specific context.
 *
 * <p>This method can be used if format type and a property version is not enough.
 */
protected Map<String, String> requiredFormatContext() {
	return Collections.emptyMap();
}