Java Code Examples for java.util.Collections.emptySet()

The following are Jave code examples for showing how to use emptySet() of the java.util.Collections class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: neoscada   File: AttributesPart.java   View Source Code Vote up 6 votes
private Set<Entry> convert ( final DataItemValue value )
{
    if ( value == null || value.getAttributes () == null )
    {
        return Collections.emptySet ();
    }

    final Set<Entry> entries = new HashSet<AttributesPart.Entry> ( value.getAttributes ().size () );

    for ( final Map.Entry<String, Variant> entry : value.getAttributes ().entrySet () )
    {
        final Variant entryValue = entry.getValue ();
        if ( entryValue != null )
        {
            entries.add ( new Entry ( entry.getKey (), entryValue.getType ().toString (), entryValue.toLabel () ) );
        }
        else
        {
            entries.add ( new Entry ( entry.getKey (), null, null ) );
        }
    }

    return entries;
}
 
Example 2
Project: ideal   File: MatcherStateMachine.java   View Source Code Vote up 6 votes
protected Collection<Pair<AccessGraph, EdgeFunction<TypestateDomainValue>>> generateAtConstructor(Unit unit,
		Collection<SootMethod> calledMethod, MatcherTransition initialTrans) {
	boolean matches = false;
	for (SootMethod method : calledMethod) {
		if (initialTrans.matches(method)) {
			matches = true;
		}
	}
	if (!matches)
		return Collections.emptySet();
	if (unit instanceof Stmt) {
		Stmt stmt = (Stmt) unit;
		if (stmt.containsInvokeExpr())
			if (stmt.getInvokeExpr() instanceof InstanceInvokeExpr) {
				InstanceInvokeExpr iie = (InstanceInvokeExpr) stmt.getInvokeExpr();
				if (iie.getBase() instanceof Local) {
					Local l = (Local) iie.getBase();
					Set<Pair<AccessGraph, EdgeFunction<TypestateDomainValue>>> out = new HashSet<>();
					out.add(new Pair<AccessGraph, EdgeFunction<TypestateDomainValue>>(
							new AccessGraph(l, l.getType()), new TransitionFunction(initialTrans)));
					return out;
				}
			}
	}
	return Collections.emptySet();
}
 
Example 3
Project: incubator-netbeans   File: TokenHierarchyOperation.java   View Source Code Vote up 6 votes
public Set<LanguagePath> languagePaths() {
    ensureReadLocked();
    Set<LanguagePath> lps;
    synchronized (rootTokenList) {
        lps = languagePaths;
        if (lps == null) {
            if (!isActiveImpl())
                return Collections.emptySet();
            Language<?> lang = rootTokenList.language();
            LanguageOperation<?> langOp = LexerApiPackageAccessor.get().languageOperation(lang);
            @SuppressWarnings("unchecked")
            Set<LanguagePath> clps = (Set<LanguagePath>)
                    ((HashSet<LanguagePath>)langOp.languagePaths()).clone();
            lps = clps;

            @SuppressWarnings("unchecked")
            Set<Language<?>> cel = (Set<Language<?>>)
                    ((HashSet<Language<?>>)langOp.exploredLanguages()).clone();
            exploredLanguages = cel;
            languagePaths = lps;
        }
    }
    return lps;
}
 
Example 4
Project: fresco_floodlight   File: SwitchSyncRepresentation.java   View Source Code Vote up 6 votes
@JsonIgnore
public OFFeaturesReply getFeaturesReply(OFFactory factory) {
	/**
     * FIXME Icky work around; if a null actions got written to storage
     * then fake up an empty one so the builder() doesn't throw
     * a NPE.  Need to root cause why someone would write a null actions.
     * This code will all be removed shortly -- needed to unblock BVS team.
     */
    Set<OFActionType> workAroundActions;
    if (actions != null)
        workAroundActions = actions;
    else
        workAroundActions = Collections.<OFActionType> emptySet();

    OFFeaturesReply featuresReply = factory.buildFeaturesReply()
            .setXid(0)
            .setDatapathId(dpid)
            .setNBuffers(buffers)
            .setNTables(tables)
            .setCapabilities(capabilities)
            .setActions(workAroundActions)
            .setPorts(toOFPortDescList(factory, ports))
            .build();
    return featuresReply;
}
 
Example 5
Project: ideal   File: HasNextStateMachine.java   View Source Code Vote up 5 votes
@Override
public Set<Transition> getReturnTransitionsFor(AccessGraph callerD1, Unit callSite,
    SootMethod calleeMethod, Unit exitStmt, AccessGraph exitNode, Unit returnSite,
    AccessGraph retNode) {
  if (retrieveHasNextMethods().contains(calleeMethod)) {
    if (icfg.getMethodOf(callSite).getSignature().contains("java.lang.Object next()"))
      return Collections.emptySet();
  }

  return super.getReturnTransitionsFor(callerD1, callSite, calleeMethod, exitStmt, exitNode, returnSite, retNode);
}
 
Example 6
Project: incubator-netbeans   File: EqualsHashCodeGenerator.java   View Source Code Vote up 5 votes
public static void generateEqualsAndHashCode(WorkingCopy wc, TreePath path) {
    ExecutableElement[] arr = overridesHashCodeAndEquals(wc, wc.getTrees().getElement(path), null);

    Collection<VariableElement> e = arr[0] == null ? Collections.<VariableElement>emptySet() : null;
    Collection<VariableElement> h = arr[1] == null ? Collections.<VariableElement>emptySet() : null;

    generateEqualsAndHashCode(wc, path, e, h, -1);
}
 
Example 7
Project: incubator-netbeans   File: PluginImporter.java   View Source Code Vote up 5 votes
private static Collection<String> getPluginFiles (File cluster, String cnb, File updateTracking) {
    Collection<String> res = new HashSet<String> ();
    LOG.log(Level.FINE, "Read update_tracking " + updateTracking + " file.");
    Node updateTrackingConf = getUpdateTrackingConf(updateTracking);
    if (updateTrackingConf == null) {
        return Collections.emptySet();
    }
    Set<String> moduleFiles = readModuleFiles(updateTrackingConf);
    String configFile = "config/Modules/" + cnb.replace ('.', '-') + ".xml"; // NOI18N

    moduleFiles.remove (configFile);

    for (String fileName : moduleFiles) {
        File file = new File (cluster, fileName);
        if (! file.exists ()) {
            LOG.log (Level.WARNING, "File " + file + " doesn't exist for module " + cnb);
            continue;
        }
        if (file.equals (updateTracking)) {
            continue;
        }
        res.add (fileName);
    }

    res.add (TRACKING_FILE_NAME + '/' + cnb.replace ('.', '-') + ".xml"); // NOI18N);

    LOG.log(Level.FINEST, cnb + " has files: " + res);
    return res;
}
 
Example 8
Project: hdt-gremlin   File: HDTVertex.java   View Source Code Vote up 5 votes
@Override
public Set<String> keys() {
	if(role==TripleComponentRole.OBJECT && id>graph.getNShared()) {
		return Collections.emptySet();
	}
	return new VertexPropertySet(this);
}
 
Example 9
Project: openjdk-jdk10   File: JavacElements.java   View Source Code Vote up 5 votes
@Override @DefinedBy(Api.LANGUAGE_MODEL)
public Set<? extends ModuleElement> getAllModuleElements() {
    if (allowModules)
        return Collections.unmodifiableSet(modules.allModules());
    else
        return Collections.emptySet();
}
 
Example 10
Project: keti   File: SubjectAttributeResolver.java   View Source Code Vote up 5 votes
public SubjectAttributeResolver(final SubjectAttributeReader subjectAttributeReader, final String subjectIdentifier,
        final Set<Attribute> supplementalSubjectAttributes) {
    this.subjectAttributeReader = subjectAttributeReader;
    this.subjectIdentifier = subjectIdentifier;
    if (null == supplementalSubjectAttributes) {
        this.supplementalSubjectAttributes = Collections.emptySet();
    } else {
        this.supplementalSubjectAttributes = supplementalSubjectAttributes;
    }
}
 
Example 11
Project: athena   File: PcepTunnelAddedTest.java   View Source Code Vote up 5 votes
@Override
public Collection<Tunnel> queryTunnel(TunnelEndPoint src, TunnelEndPoint dst) {
    Collection<Tunnel> result = new HashSet<>();
    Tunnel tunnel = null;
    for (TunnelId tunnelId : tunnelIdAsKeyStore.keySet()) {
        tunnel = tunnelIdAsKeyStore.get(tunnelId);

        if ((null != tunnel) && (src.equals(tunnel.src())) && (dst.equals(tunnel.dst()))) {
            result.add(tunnel);
        }
    }

    return result.isEmpty() ? Collections.emptySet() : ImmutableSet.copyOf(result);
}
 
Example 12
Project: monarch   File: GMSJoinLeaveJUnitTest.java   View Source Code Vote up 5 votes
@Test
public void testNetworkPartitionDetected() throws IOException {
  initMocks(true);
  prepareAndInstallView(mockMembers[0], createMemberList(mockMembers[0], gmsJoinLeaveMemberId));

  // set up a view with sufficient members, then create a new view
  // where enough weight is lost to cause a network partition

  List<InternalDistributedMember> mbrs = new LinkedList<>();
  mbrs.add(mockMembers[0]);
  mbrs.add(mockMembers[1]);
  mbrs.add(mockMembers[2]);
  mbrs.add(gmsJoinLeaveMemberId);

  ((GMSMember) mockMembers[1].getNetMember()).setMemberWeight((byte) 20);

  NetView newView = new NetView(mockMembers[0], gmsJoinLeave.getView().getViewId() + 1, mbrs);
  InstallViewMessage installViewMessage = getInstallViewMessage(newView, credentials, false);
  gmsJoinLeave.processMessage(installViewMessage);

  Set<InternalDistributedMember> crashes = new HashSet<>();
  crashes.add(mockMembers[1]);
  crashes.add(mockMembers[2]);
  mbrs = new LinkedList<>(mbrs);
  mbrs.remove(mockMembers[1]);
  mbrs.remove(mockMembers[2]);
  NetView partitionView =
      new NetView(mockMembers[0], newView.getViewId() + 1, mbrs, Collections.emptySet(), crashes);
  installViewMessage = getInstallViewMessage(partitionView, credentials, false);
  gmsJoinLeave.processMessage(installViewMessage);

  verify(manager).forceDisconnect(isA(String.class));
  verify(manager).quorumLost(crashes, newView);
}
 
Example 13
Project: hashsdn-controller   File: DataSchemaContainerProxy.java   View Source Code Vote up 4 votes
@Override
public Set<UsesNode> getUses() {
    return Collections.emptySet();
}
 
Example 14
Project: incubator-netbeans   File: MavenWhiteListQueryImpl.java   View Source Code Vote up 4 votes
public MavenWhiteListQueryImpl(Project prj) {
    project = prj;
    projectListener = new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            //TODO listen just on changes of classpath??
            if (NbMavenProject.PROP_PROJECT.equals(evt.getPropertyName())) {
                synchronized (LOCK) {
                    Set<String> oldPrivate = cachePrivatePackages != null ? cachePrivatePackages.get() : null;
                    if (oldPrivate == null) {
                        oldPrivate = Collections.emptySet();
                    }
                    Set<String> oldTransitive = cacheTransitivePackages != null ? cacheTransitivePackages.get() : null;
                    if (oldTransitive == null) {
                        oldTransitive = Collections.emptySet();
                    }
                    isCached = false;
                    cacheOrLoad();
                    Set<String> newPrivate = cachePrivatePackages != null ? cachePrivatePackages.get() : null;
                    if (newPrivate == null) {
                        newPrivate = Collections.emptySet();
                    }
                    Set<String> newTransitive = cacheTransitivePackages != null ? cacheTransitivePackages.get() : null;
                    if (newTransitive == null) {
                        newTransitive = Collections.emptySet();
                    }
                    HashSet oldNotNew1 = new HashSet(oldPrivate);
                    oldNotNew1.removeAll(newPrivate);
                    HashSet newNotOld1 = new HashSet(newPrivate);
                    newNotOld1.removeAll(oldPrivate);
                    HashSet oldNotNew2 = new HashSet(oldTransitive);
                    oldNotNew2.removeAll(newTransitive);
                    HashSet newNotOld2 = new HashSet(newTransitive);
                    newNotOld2.removeAll(oldTransitive);
                    
                    boolean privateChanged = !oldNotNew1.isEmpty() || !newNotOld1.isEmpty();
                    boolean transitiveChanged = !oldNotNew2.isEmpty() || !newNotOld2.isEmpty();
                    if (privateChanged || transitiveChanged) {
                        ClassPath[] cps = project.getLookup().lookup(ProjectSourcesClassPathProvider.class).getProjectClassPaths(ClassPath.SOURCE);
                        Set<FileObject> fos = new HashSet<FileObject>();
                        for (ClassPath cp : cps) {
                            fos.addAll(Arrays.asList(cp.getRoots()));
                        }
                        LOG.log(Level.INFO, "Refreshing indexes for {0} because {1}{2} changed.", new Object[]{project.getProjectDirectory(), privateChanged ? "accessible private packages, " : "", transitiveChanged ? "accessible transitive packages " : ""});
                        LOG.log(Level.FINE, "changes in private1-{0}", Arrays.toString(oldNotNew1.toArray()));
                        LOG.log(Level.FINE, "changes in private2-{0}", Arrays.toString(newNotOld1.toArray()));
                        LOG.log(Level.FINE, "changes in transitive1-{0}", Arrays.toString(oldNotNew2.toArray()));
                        LOG.log(Level.FINE, "changes in transitive2-{0}", Arrays.toString(newNotOld2.toArray()));
                        IndexingManager.getDefault().refreshAllIndices(fos.toArray(new FileObject[0]));
                    }
                }
            }
        }
    };
}
 
Example 15
Project: incubator-netbeans   File: VisibilityChangeTest.java   View Source Code Vote up 4 votes
@Override
public Set<String> getLibraryPathIds() {
    return Collections.<String>emptySet();
}
 
Example 16
Project: openNaEF   File: OfPatchLink.java   View Source Code Vote up 4 votes
@Override public Collection<? extends Port> getCurrentMemberPorts() {
    return Collections.<Port>emptySet();
}
 
Example 17
Project: incubator-netbeans   File: FileQueryTest.java   View Source Code Vote up 4 votes
@Override
public Set<String> getBinaryLibraryPathIds() {
    return Collections.<String>emptySet();
}
 
Example 18
Project: incubator-netbeans   File: TestJavaPlatform.java   View Source Code Vote up 4 votes
@Override
public Collection<FileObject> getInstallFolders() {
    return Collections.<FileObject>emptySet();
}
 
Example 19
Project: X4J   File: ConcurrentReferenceHashMap.java   View Source Code Vote up 4 votes
/**
 * Restructure the underlying data structure when it becomes necessary.
 * This method can increase the size of the references table as well as
 * purge any references that have been garbage collected.
 * 
 * @param allowResize
 *            if resizing is permitted
 */
protected final void restructureIfNecessary(boolean allowResize) {
	boolean needsResize = ((this.count > 0) && (this.count >= this.resizeThreshold));
	Reference<K, V> reference = this.referenceManager.pollForPurge();
	if ((reference != null) || (needsResize && allowResize)) {
		lock();
		try {
			int countAfterRestructure = this.count;

			Set<Reference<K, V>> toPurge = Collections.emptySet();
			if (reference != null) {
				toPurge = new HashSet<Reference<K, V>>();
				while (reference != null) {
					toPurge.add(reference);
					reference = this.referenceManager.pollForPurge();
				}
			}
			countAfterRestructure -= toPurge.size();

			// Recalculate taking into account count inside lock and
			// items that
			// will be purged
			needsResize = (countAfterRestructure > 0 && countAfterRestructure >= this.resizeThreshold);
			boolean resizing = false;
			int restructureSize = this.references.length;
			if (allowResize && needsResize && restructureSize < MAXIMUM_SEGMENT_SIZE) {
				restructureSize <<= 1;
				resizing = true;
			}

			// Either create a new table or reuse the existing one
			Reference<K, V>[] restructured = (resizing ? createReferenceArray(restructureSize)
					: this.references);

			// Restructure
			for (int i = 0; i < this.references.length; i++) {
				reference = this.references[i];
				if (!resizing) {
					restructured[i] = null;
				}
				while (reference != null) {
					if (!toPurge.contains(reference)) {
						Entry<K, V> entry = reference.get();
						if (entry != null) {
							int index = getIndex(reference.getHash(), restructured);
							restructured[index] = this.referenceManager.createReference(entry,
									reference.getHash(), restructured[index]);
						}
					}
					reference = reference.getNext();
				}
			}

			// Replace volatile members
			if (resizing) {
				this.references = restructured;
				this.resizeThreshold = (int) (this.references.length * getLoadFactor());
			}
			this.count = Math.max(countAfterRestructure, 0);
		} finally {
			unlock();
		}
	}
}
 
Example 20
Project: incubator-netbeans   File: CssElement.java   View Source Code Vote up 4 votes
@Override
public Set<Modifier> getModifiers() {
    return Collections.emptySet();
}