Java Code Examples for java.util.LinkedHashSet#isEmpty()
The following examples show how to use
java.util.LinkedHashSet#isEmpty() .
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: FunctionTransitionUtil.java From bazel with Apache License 2.0 | 6 votes |
/** * Validates that function outputs exactly the set of outputs it declares. More thorough checking * (like type checking of output values) is done elsewhere because it requires loading. see {@link * StarlarkTransition#validate} */ private static void validateFunctionOutputsMatchesDeclaredOutputs( Collection<Map<String, Object>> transitions, StarlarkDefinedConfigTransition starlarkTransition) throws EvalException { for (Map<String, Object> transition : transitions) { LinkedHashSet<String> remainingOutputs = Sets.newLinkedHashSet(starlarkTransition.getOutputs()); for (String outputKey : transition.keySet()) { if (!remainingOutputs.remove(outputKey)) { throw new EvalException( starlarkTransition.getLocationForErrorReporting(), String.format("transition function returned undeclared output '%s'", outputKey)); } } if (!remainingOutputs.isEmpty()) { throw new EvalException( starlarkTransition.getLocationForErrorReporting(), String.format( "transition outputs [%s] were not defined by transition function", Joiner.on(", ").join(remainingOutputs))); } } }
Example 2
Source File: RankChannelsAction.java From spacewalk with GNU General Public License v2.0 | 6 votes |
/** * Sets up the rangling widget. * @param context the request context of the current request * @param form the dynaform related to the current request. * @param set the set holding the channel ids. */ private void setupWidget(RequestContext context, DynaActionForm form, Set<String> set) { LinkedHashSet labelValues = new LinkedHashSet(); populateWidgetLabels(labelValues, context); for (String id : set) { Long ccid = Long.valueOf(id); ConfigChannel channel = ConfigurationFactory.lookupConfigChannelById(ccid); labelValues.add(lv(channel.getName(), channel.getId().toString())); } //set the form variables for the widget to read. form.set(POSSIBLE_CHANNELS, labelValues); if (!labelValues.isEmpty()) { if (form.get(SELECTED_CHANNEL) == null) { String selected = ((LabelValueBean)labelValues.iterator().next()) .getValue(); form.set(SELECTED_CHANNEL, selected); } } }
Example 3
Source File: H2Utils.java From ignite with Apache License 2.0 | 6 votes |
/** * Collect cache identifiers from two-step query. * * @param mainCacheId Id of main cache. * @return Result. */ public static List<Integer> collectCacheIds( IgniteH2Indexing idx, @Nullable Integer mainCacheId, Collection<QueryTable> tbls ) { LinkedHashSet<Integer> caches0 = new LinkedHashSet<>(); if (mainCacheId != null) caches0.add(mainCacheId); if (!F.isEmpty(tbls)) { for (QueryTable tblKey : tbls) { GridH2Table tbl = idx.schemaManager().dataTable(tblKey.schema(), tblKey.table()); if (tbl != null) { checkAndStartNotStartedCache(idx.kernalContext(), tbl); caches0.add(tbl.cacheId()); } } } return caches0.isEmpty() ? Collections.emptyList() : new ArrayList<>(caches0); }
Example 4
Source File: BaseRankChannels.java From uyuni with GNU General Public License v2.0 | 6 votes |
/** * Sets up the rangling widget. * @param context the request context of the current request * @param form the dynaform related to the current request. * @param set the rhnset holding the channel ids. */ protected void setupWidget(RequestContext context, DynaActionForm form, RhnSet set) { User user = context.getCurrentUser(); LinkedHashSet labelValues = new LinkedHashSet(); populateWidgetLabels(labelValues, context); for (Iterator itr = set.getElements().iterator(); itr.hasNext();) { Long ccid = ((RhnSetElement) itr.next()).getElement(); ConfigChannel channel = ConfigurationManager.getInstance() .lookupConfigChannel(user, ccid); String optionstr = channel.getName() + " (" + channel.getLabel() + ")"; labelValues.add(lv(optionstr, channel.getId().toString())); } //set the form variables for the widget to read. form.set(POSSIBLE_CHANNELS, labelValues); if (!labelValues.isEmpty()) { if (form.get(SELECTED_CHANNEL) == null) { String selected = ((LabelValueBean)labelValues.iterator().next()) .getValue(); form.set(SELECTED_CHANNEL, selected); } } }
Example 5
Source File: GenericNode.java From Bats with Apache License 2.0 | 5 votes |
protected boolean isDuplicate(LinkedHashSet<CustomControlTuple> set, CustomControlTuple t) { if (set == null || set.isEmpty()) { return false; } for (CustomControlTuple cct : set) { if (cct.getUid().equals(t.getUid())) { return true; } } return false; }
Example 6
Source File: StorageUtil.java From consulo with Apache License 2.0 | 5 votes |
public static void notifyUnknownMacros(@Nonnull TrackingPathMacroSubstitutor substitutor, @Nonnull final Project project, @Nullable final String componentName) { final LinkedHashSet<String> macros = new LinkedHashSet<String>(substitutor.getUnknownMacros(componentName)); if (macros.isEmpty()) { return; } UIUtil.invokeLaterIfNeeded(new Runnable() { @Override public void run() { macros.removeAll(getMacrosFromExistingNotifications(project)); if (!macros.isEmpty()) { LOG.debug("Reporting unknown path macros " + macros + " in component " + componentName); String format = "<p><i>%s</i> %s undefined. <a href=\"define\">Fix it</a></p>"; String productName = ApplicationNamesInfo.getInstance().getProductName(); String content = String.format(format, StringUtil.join(macros, ", "), macros.size() == 1 ? "is" : "are") + "<br>Path variables are used to substitute absolute paths " + "in " + productName + " project files " + "and allow project file sharing in version control systems.<br>" + "Some of the files describing the current project settings contain unknown path variables " + "and " + productName + " cannot restore those paths."; new UnknownMacroNotification("Load Error", "Load error: undefined path variables", content, NotificationType.ERROR, (notification, event) -> ProjectStorageUtil.checkUnknownMacros((ProjectEx)project, true), macros).notify(project); } } }); }
Example 7
Source File: FixedPointGraphTraversal.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Compute a fixed point for the given graph, entering from the given nodes. * @param graph The graph to traverse. * @param entrySet The nodes to begin traversing from. */ public void computeFixedPoint(DiGraph<N, E> graph, Set<N> entrySet) { int cycleCount = 0; long nodeCount = graph.getNodes().size(); // Choose a bail-out heuristically in case the computation // doesn't converge. long maxIterations = Math.max(nodeCount * nodeCount * nodeCount, 100); // Use a LinkedHashSet, so that the traversal is deterministic. LinkedHashSet<DiGraphNode<N, E>> workSet = Sets.newLinkedHashSet(); for (N n : entrySet) { workSet.add(graph.getDirectedGraphNode(n)); } for (; !workSet.isEmpty() && cycleCount < maxIterations; cycleCount++) { // For every out edge in the workSet, traverse that edge. If that // edge updates the state of the graph, then add the destination // node to the resultSet, so that we can update all of its out edges // on the next iteration. DiGraphNode<N, E> source = workSet.iterator().next(); N sourceValue = source.getValue(); workSet.remove(source); List<DiGraphEdge<N, E>> outEdges = source.getOutEdges(); for (DiGraphEdge<N, E> edge : outEdges) { N destNode = edge.getDestination().getValue(); if (callback.traverseEdge(sourceValue, edge.getValue(), destNode)) { workSet.add(edge.getDestination()); } } } Preconditions.checkState(cycleCount != maxIterations, NON_HALTING_ERROR_MSG); }
Example 8
Source File: JavaProject.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * @see IJavaProject */ public boolean hasClasspathCycle(IClasspathEntry[] preferredClasspath) { LinkedHashSet cycleParticipants = new LinkedHashSet(); HashMap preferredClasspaths = new HashMap(1); preferredClasspaths.put(this, preferredClasspath); updateCycleParticipants(new ArrayList(2), cycleParticipants, ResourcesPlugin.getWorkspace().getRoot(), new HashSet(2), preferredClasspaths); return !cycleParticipants.isEmpty(); }
Example 9
Source File: StubUtility.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public static String[] getVariableNameSuggestions(int variableKind, IJavaProject project, ITypeBinding expectedType, Expression assignedExpression, Collection<String> excluded) { LinkedHashSet<String> res= new LinkedHashSet<String>(); // avoid duplicates but keep order if (assignedExpression != null) { String nameFromExpression= getBaseNameFromExpression(project, assignedExpression, variableKind); if (nameFromExpression != null) { add(getVariableNameSuggestions(variableKind, project, nameFromExpression, 0, excluded, false), res); // pass 0 as dimension, base name already contains plural. } String nameFromParent= getBaseNameFromLocationInParent(assignedExpression); if (nameFromParent != null) { add(getVariableNameSuggestions(variableKind, project, nameFromParent, 0, excluded, false), res); // pass 0 as dimension, base name already contains plural. } } if (expectedType != null) { expectedType= Bindings.normalizeTypeBinding(expectedType); if (expectedType != null) { int dim= 0; if (expectedType.isArray()) { dim= expectedType.getDimensions(); expectedType= expectedType.getElementType(); } if (expectedType.isParameterizedType()) { expectedType= expectedType.getTypeDeclaration(); } String typeName= expectedType.getName(); if (typeName.length() > 0) { add(getVariableNameSuggestions(variableKind, project, typeName, dim, excluded, false), res); } } } if (res.isEmpty()) { return getDefaultVariableNameSuggestions(variableKind, excluded); } return res.toArray(new String[res.size()]); }
Example 10
Source File: EditboxPreferencePage.java From gama with GNU General Public License v3.0 | 4 votes |
public String[] namesArray(final String name) { final LinkedHashSet<String> set = categoryFiles.get(name); if (set == null || set.isEmpty()) { return new String[0]; } return set.toArray(new String[0]); }
Example 11
Source File: SystemFlavorMap.java From JDKSourceCode1.8 with MIT License | 4 votes |
/** * Semantically equivalent to 'flavorToNative.get(flav)'. This method * handles the case where 'flav' is not found in 'flavorToNative' depending * on the value of passes 'synthesize' parameter. If 'synthesize' is * SYNTHESIZE_IF_NOT_FOUND a native is synthesized, stored, and returned by * encoding the DataFlavor's MIME type. Otherwise an empty List is returned * and 'flavorToNative' remains unaffected. */ private LinkedHashSet<String> flavorToNativeLookup(final DataFlavor flav, final boolean synthesize) { LinkedHashSet<String> natives = getFlavorToNative().get(flav); if (flav != null && !disabledMappingGenerationKeys.contains(flav)) { DataTransferer transferer = DataTransferer.getInstance(); if (transferer != null) { LinkedHashSet<String> platformNatives = transferer.getPlatformMappingsForFlavor(flav); if (!platformNatives.isEmpty()) { if (natives != null) { // Prepend the platform-specific mappings to ensure // that the natives added with // addUnencodedNativeForFlavor() are at the end of // list. platformNatives.addAll(natives); } natives = platformNatives; } } } if (natives == null) { if (synthesize) { String encoded = encodeDataFlavor(flav); natives = new LinkedHashSet<>(1); getFlavorToNative().put(flav, natives); natives.add(encoded); LinkedHashSet<DataFlavor> flavors = getNativeToFlavor().get(encoded); if (flavors == null) { flavors = new LinkedHashSet<>(1); getNativeToFlavor().put(encoded, flavors); } flavors.add(flav); nativesForFlavorCache.remove(flav); flavorsForNativeCache.remove(encoded); } else { natives = new LinkedHashSet<>(0); } } return new LinkedHashSet<>(natives); }
Example 12
Source File: GenericsUtil.java From redant with Apache License 2.0 | 4 votes |
/** * 获取ipV4 * @return ipV4 */ public static String getLocalIpV4(){ LinkedHashSet<String> ipV4Set = NetUtil.localIpv4s(); return ipV4Set.isEmpty()?"":ipV4Set.toArray()[0].toString(); }
Example 13
Source File: SystemFlavorMap.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
/** * Semantically equivalent to 'flavorToNative.get(flav)'. This method * handles the case where 'flav' is not found in 'flavorToNative' depending * on the value of passes 'synthesize' parameter. If 'synthesize' is * SYNTHESIZE_IF_NOT_FOUND a native is synthesized, stored, and returned by * encoding the DataFlavor's MIME type. Otherwise an empty List is returned * and 'flavorToNative' remains unaffected. */ private LinkedHashSet<String> flavorToNativeLookup(final DataFlavor flav, final boolean synthesize) { LinkedHashSet<String> natives = getFlavorToNative().get(flav); if (flav != null && !disabledMappingGenerationKeys.contains(flav)) { DataTransferer transferer = DataTransferer.getInstance(); if (transferer != null) { LinkedHashSet<String> platformNatives = transferer.getPlatformMappingsForFlavor(flav); if (!platformNatives.isEmpty()) { if (natives != null) { // Prepend the platform-specific mappings to ensure // that the natives added with // addUnencodedNativeForFlavor() are at the end of // list. platformNatives.addAll(natives); } natives = platformNatives; } } } if (natives == null) { if (synthesize) { String encoded = encodeDataFlavor(flav); natives = new LinkedHashSet<>(1); getFlavorToNative().put(flav, natives); natives.add(encoded); LinkedHashSet<DataFlavor> flavors = getNativeToFlavor().get(encoded); if (flavors == null) { flavors = new LinkedHashSet<>(1); getNativeToFlavor().put(encoded, flavors); } flavors.add(flav); nativesForFlavorCache.remove(flav); flavorsForNativeCache.remove(encoded); } else { natives = new LinkedHashSet<>(0); } } return new LinkedHashSet<>(natives); }
Example 14
Source File: SystemFlavorMap.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
/** * Semantically equivalent to 'nativeToFlavor.get(nat)'. This method * handles the case where 'nat' is not found in 'nativeToFlavor'. In that * case, a new DataFlavor is synthesized, stored, and returned, if and * only if the specified native is encoded as a Java MIME type. */ private LinkedHashSet<DataFlavor> nativeToFlavorLookup(String nat) { LinkedHashSet<DataFlavor> flavors = getNativeToFlavor().get(nat); if (nat != null && !disabledMappingGenerationKeys.contains(nat)) { DataTransferer transferer = DataTransferer.getInstance(); if (transferer != null) { LinkedHashSet<DataFlavor> platformFlavors = transferer.getPlatformMappingsForNative(nat); if (!platformFlavors.isEmpty()) { if (flavors != null) { // Prepending the platform-specific mappings ensures // that the flavors added with // addFlavorForUnencodedNative() are at the end of // list. platformFlavors.addAll(flavors); } flavors = platformFlavors; } } } if (flavors == null && isJavaMIMEType(nat)) { String decoded = decodeJavaMIMEType(nat); DataFlavor flavor = null; try { flavor = new DataFlavor(decoded); } catch (Exception e) { System.err.println("Exception \"" + e.getClass().getName() + ": " + e.getMessage() + "\"while constructing DataFlavor for: " + decoded); } if (flavor != null) { flavors = new LinkedHashSet<>(1); getNativeToFlavor().put(nat, flavors); flavors.add(flavor); flavorsForNativeCache.remove(nat); LinkedHashSet<String> natives = getFlavorToNative().get(flavor); if (natives == null) { natives = new LinkedHashSet<>(1); getFlavorToNative().put(flavor, natives); } natives.add(nat); nativesForFlavorCache.remove(flavor); } } return (flavors != null) ? flavors : new LinkedHashSet<>(0); }
Example 15
Source File: LowestCommonAncestor.java From Concurnas with MIT License | 4 votes |
public NamedType go() { if(!this.objTypes.isEmpty()) { ArrayList<LinkedHashSet<NamedType>> searchLists = new ArrayList<LinkedHashSet<NamedType>>(this.objTypes.size()); for(NamedType cls : this.objTypes) { searchLists.add(justGetBFSOrder(cls)); } //Start with shotest list cos if only 1 element then much quicker than searching everything LinkedHashSet<NamedType> shortestList = getShortestList(searchLists); //merge in nullableGenercs //shortestList = mergeInNullgenerics(shortestList, searchLists); if(searchLists.isEmpty()) { NamedType headofShortestList = shortestList.iterator().next(); if(null == headofShortestList) { headofShortestList = failObj; } return headofShortestList; } LinkedHashSet<NamedType> foundMatches = new LinkedHashSet<NamedType>(); for(NamedType searchItem : shortestList) { if(!this.resolvedAlready.contains(searchItem)) {//ensure that we've not already visited this type //avoids inf loop on things like X < Enum<X> and Y < Enum<Y> this.resolvedAlready.add(searchItem); NamedType found =findInKidOthers(searchItem, searchLists); if(found != null) { foundMatches.add(found); } } } if(!foundMatches.isEmpty()) { if(onlyInstantiableRefTypes){//filter out everything which we cannot directly instantiate (e.g. interfaces, abstract types etc) - used for ArrayDefs etc LinkedHashSet<NamedType> foundMatchesfiltered = new LinkedHashSet<NamedType>(); for(NamedType potential : foundMatches) { ClassDef cd = potential.getSetClassDef(); if(null != cd){ if(!cd.isInstantiable()){ continue; } } foundMatchesfiltered.add(potential); } if(!foundMatchesfiltered.isEmpty()){ return new NamedTypeMany(foundMatchesfiltered); } }else{ return new NamedTypeMany(foundMatches); } } } //everything inherits from object return failObj; }
Example 16
Source File: SystemFlavorMap.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
/** * Semantically equivalent to 'flavorToNative.get(flav)'. This method * handles the case where 'flav' is not found in 'flavorToNative' depending * on the value of passes 'synthesize' parameter. If 'synthesize' is * SYNTHESIZE_IF_NOT_FOUND a native is synthesized, stored, and returned by * encoding the DataFlavor's MIME type. Otherwise an empty List is returned * and 'flavorToNative' remains unaffected. */ private LinkedHashSet<String> flavorToNativeLookup(final DataFlavor flav, final boolean synthesize) { LinkedHashSet<String> natives = getFlavorToNative().get(flav); if (flav != null && !disabledMappingGenerationKeys.contains(flav)) { DataTransferer transferer = DataTransferer.getInstance(); if (transferer != null) { LinkedHashSet<String> platformNatives = transferer.getPlatformMappingsForFlavor(flav); if (!platformNatives.isEmpty()) { if (natives != null) { // Prepend the platform-specific mappings to ensure // that the natives added with // addUnencodedNativeForFlavor() are at the end of // list. platformNatives.addAll(natives); } natives = platformNatives; } } } if (natives == null) { if (synthesize) { String encoded = encodeDataFlavor(flav); natives = new LinkedHashSet<>(1); getFlavorToNative().put(flav, natives); natives.add(encoded); LinkedHashSet<DataFlavor> flavors = getNativeToFlavor().get(encoded); if (flavors == null) { flavors = new LinkedHashSet<>(1); getNativeToFlavor().put(encoded, flavors); } flavors.add(flav); nativesForFlavorCache.remove(flav); flavorsForNativeCache.remove(encoded); } else { natives = new LinkedHashSet<>(0); } } return new LinkedHashSet<>(natives); }
Example 17
Source File: SystemFlavorMap.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
/** * Semantically equivalent to 'flavorToNative.get(flav)'. This method * handles the case where 'flav' is not found in 'flavorToNative' depending * on the value of passes 'synthesize' parameter. If 'synthesize' is * SYNTHESIZE_IF_NOT_FOUND a native is synthesized, stored, and returned by * encoding the DataFlavor's MIME type. Otherwise an empty List is returned * and 'flavorToNative' remains unaffected. */ private LinkedHashSet<String> flavorToNativeLookup(final DataFlavor flav, final boolean synthesize) { LinkedHashSet<String> natives = getFlavorToNative().get(flav); if (flav != null && !disabledMappingGenerationKeys.contains(flav)) { DataTransferer transferer = DataTransferer.getInstance(); if (transferer != null) { LinkedHashSet<String> platformNatives = transferer.getPlatformMappingsForFlavor(flav); if (!platformNatives.isEmpty()) { if (natives != null) { // Prepend the platform-specific mappings to ensure // that the natives added with // addUnencodedNativeForFlavor() are at the end of // list. platformNatives.addAll(natives); } natives = platformNatives; } } } if (natives == null) { if (synthesize) { String encoded = encodeDataFlavor(flav); natives = new LinkedHashSet<>(1); getFlavorToNative().put(flav, natives); natives.add(encoded); LinkedHashSet<DataFlavor> flavors = getNativeToFlavor().get(encoded); if (flavors == null) { flavors = new LinkedHashSet<>(1); getNativeToFlavor().put(encoded, flavors); } flavors.add(flav); nativesForFlavorCache.remove(flav); flavorsForNativeCache.remove(encoded); } else { natives = new LinkedHashSet<>(0); } } return new LinkedHashSet<>(natives); }
Example 18
Source File: SystemFlavorMap.java From Java8CN with Apache License 2.0 | 4 votes |
/** * Semantically equivalent to 'flavorToNative.get(flav)'. This method * handles the case where 'flav' is not found in 'flavorToNative' depending * on the value of passes 'synthesize' parameter. If 'synthesize' is * SYNTHESIZE_IF_NOT_FOUND a native is synthesized, stored, and returned by * encoding the DataFlavor's MIME type. Otherwise an empty List is returned * and 'flavorToNative' remains unaffected. */ private LinkedHashSet<String> flavorToNativeLookup(final DataFlavor flav, final boolean synthesize) { LinkedHashSet<String> natives = getFlavorToNative().get(flav); if (flav != null && !disabledMappingGenerationKeys.contains(flav)) { DataTransferer transferer = DataTransferer.getInstance(); if (transferer != null) { LinkedHashSet<String> platformNatives = transferer.getPlatformMappingsForFlavor(flav); if (!platformNatives.isEmpty()) { if (natives != null) { // Prepend the platform-specific mappings to ensure // that the natives added with // addUnencodedNativeForFlavor() are at the end of // list. platformNatives.addAll(natives); } natives = platformNatives; } } } if (natives == null) { if (synthesize) { String encoded = encodeDataFlavor(flav); natives = new LinkedHashSet<>(1); getFlavorToNative().put(flav, natives); natives.add(encoded); LinkedHashSet<DataFlavor> flavors = getNativeToFlavor().get(encoded); if (flavors == null) { flavors = new LinkedHashSet<>(1); getNativeToFlavor().put(encoded, flavors); } flavors.add(flav); nativesForFlavorCache.remove(flav); flavorsForNativeCache.remove(encoded); } else { natives = new LinkedHashSet<>(0); } } return new LinkedHashSet<>(natives); }
Example 19
Source File: SystemFlavorMap.java From jdk1.8-source-analysis with Apache License 2.0 | 4 votes |
/** * Semantically equivalent to 'flavorToNative.get(flav)'. This method * handles the case where 'flav' is not found in 'flavorToNative' depending * on the value of passes 'synthesize' parameter. If 'synthesize' is * SYNTHESIZE_IF_NOT_FOUND a native is synthesized, stored, and returned by * encoding the DataFlavor's MIME type. Otherwise an empty List is returned * and 'flavorToNative' remains unaffected. */ private LinkedHashSet<String> flavorToNativeLookup(final DataFlavor flav, final boolean synthesize) { LinkedHashSet<String> natives = getFlavorToNative().get(flav); if (flav != null && !disabledMappingGenerationKeys.contains(flav)) { DataTransferer transferer = DataTransferer.getInstance(); if (transferer != null) { LinkedHashSet<String> platformNatives = transferer.getPlatformMappingsForFlavor(flav); if (!platformNatives.isEmpty()) { if (natives != null) { // Prepend the platform-specific mappings to ensure // that the natives added with // addUnencodedNativeForFlavor() are at the end of // list. platformNatives.addAll(natives); } natives = platformNatives; } } } if (natives == null) { if (synthesize) { String encoded = encodeDataFlavor(flav); natives = new LinkedHashSet<>(1); getFlavorToNative().put(flav, natives); natives.add(encoded); LinkedHashSet<DataFlavor> flavors = getNativeToFlavor().get(encoded); if (flavors == null) { flavors = new LinkedHashSet<>(1); getNativeToFlavor().put(encoded, flavors); } flavors.add(flav); nativesForFlavorCache.remove(flav); flavorsForNativeCache.remove(encoded); } else { natives = new LinkedHashSet<>(0); } } return new LinkedHashSet<>(natives); }
Example 20
Source File: SystemFlavorMap.java From hottub with GNU General Public License v2.0 | 4 votes |
/** * Semantically equivalent to 'flavorToNative.get(flav)'. This method * handles the case where 'flav' is not found in 'flavorToNative' depending * on the value of passes 'synthesize' parameter. If 'synthesize' is * SYNTHESIZE_IF_NOT_FOUND a native is synthesized, stored, and returned by * encoding the DataFlavor's MIME type. Otherwise an empty List is returned * and 'flavorToNative' remains unaffected. */ private LinkedHashSet<String> flavorToNativeLookup(final DataFlavor flav, final boolean synthesize) { LinkedHashSet<String> natives = getFlavorToNative().get(flav); if (flav != null && !disabledMappingGenerationKeys.contains(flav)) { DataTransferer transferer = DataTransferer.getInstance(); if (transferer != null) { LinkedHashSet<String> platformNatives = transferer.getPlatformMappingsForFlavor(flav); if (!platformNatives.isEmpty()) { if (natives != null) { // Prepend the platform-specific mappings to ensure // that the natives added with // addUnencodedNativeForFlavor() are at the end of // list. platformNatives.addAll(natives); } natives = platformNatives; } } } if (natives == null) { if (synthesize) { String encoded = encodeDataFlavor(flav); natives = new LinkedHashSet<>(1); getFlavorToNative().put(flav, natives); natives.add(encoded); LinkedHashSet<DataFlavor> flavors = getNativeToFlavor().get(encoded); if (flavors == null) { flavors = new LinkedHashSet<>(1); getNativeToFlavor().put(encoded, flavors); } flavors.add(flav); nativesForFlavorCache.remove(flav); flavorsForNativeCache.remove(encoded); } else { natives = new LinkedHashSet<>(0); } } return new LinkedHashSet<>(natives); }