List of usage examples for java.util Collections EMPTY_SET
Set EMPTY_SET
To view the source code for java.util Collections EMPTY_SET.
Click Source Link
From source file:net.sourceforge.fenixedu.domain.Enrolment.java
@Override @SuppressWarnings("unchecked") final public Curriculum getCurriculum(final DateTime when, final ExecutionYear year) { if (wasCreated(when) && (year == null || getExecutionYear().isBefore(year)) && isApproved() && !isPropaedeutic() && !isExtraCurricular()) { return new Curriculum(this, year, Collections.singleton((ICurriculumEntry) this), Collections.EMPTY_SET, Collections.singleton((ICurriculumEntry) this)); }// www .j av a 2s . c om return Curriculum.createEmpty(this, year); }
From source file:com.phoenixst.plexus.DefaultGraph.java
/** * A special-case edge collection.// w w w . j a v a2 s . c om */ private Collection edgesHelper(EdgePredicate edgePredicate) { Object nodeA = edgePredicate.getFirstNodeSpecification(); Object nodeB = edgePredicate.getSecondNodeSpecification(); Object userObject = edgePredicate.getUserObjectSpecification(); int directionFlags = edgePredicate.getDirectionFlags(); // Check for either node being fixed PredicateSpec nodeAType = getSpecType(nodeA); if (nodeAType == PredicateSpec.EQUALS_PREDICATE || nodeAType == PredicateSpec.OBJECT) { if (nodeAType == PredicateSpec.EQUALS_PREDICATE) { nodeA = ((EqualPredicate) nodeA).getTestObject(); } AdjacencyList adj = (AdjacencyList) nodeMap.get(nodeA); if (adj != null) { CursorFilter filter = createCursorFilter(nodeB, userObject, directionFlags); if (filter != FALSE_CURSOR_FILTER) { if (LOGGER.isDebugEnabled()) { LOGGER.debug( " " + instanceString + ".edges() returning some edges incident to " + adj.node); } return new IncEdgeCollection(adj, filter); } } if (LOGGER.isDebugEnabled()) { LOGGER.debug(" " + instanceString + ".edges() returning empty set"); } return Collections.EMPTY_SET; } PredicateSpec nodeBType = getSpecType(nodeB); if (nodeBType == PredicateSpec.EQUALS_PREDICATE || nodeBType == PredicateSpec.OBJECT) { if (nodeBType == PredicateSpec.EQUALS_PREDICATE) { nodeB = ((EqualPredicate) nodeB).getTestObject(); } AdjacencyList adj = (AdjacencyList) nodeMap.get(nodeB); if (adj != null) { CursorFilter filter = createCursorFilter(nodeA, userObject, GraphUtils.invertDirection(directionFlags)); if (filter != FALSE_CURSOR_FILTER) { if (LOGGER.isDebugEnabled()) { LOGGER.debug( " " + instanceString + ".edges() returning some edges incident to " + adj.node); } return new IncEdgeCollection(adj, filter); } } if (LOGGER.isDebugEnabled()) { LOGGER.debug(" " + instanceString + ".edges() returning empty set"); } return Collections.EMPTY_SET; } // Convert userObject to a Predicate Predicate userPredicate = toPredicate(userObject); // If we reach this point, both nodes are either of PredicateSpec.ANY // or PredicateSpec.PREDICATE if (nodeAType == PredicateSpec.ANY && nodeBType == PredicateSpec.ANY) { if (userPredicate == TruePredicate.INSTANCE) { if ((directionFlags & GraphUtils.UNDIRECTED_MASK) == 0) { if (LOGGER.isDebugEnabled()) { LOGGER.debug(" " + instanceString + ".edges() returning all directed edges"); } return new AnyToAnyEdgeCollection(GraphUtils.DIRECTED_EDGE_PREDICATE, BASE_TAIL_DIRECTED_CURSOR_FILTER); } else if ((directionFlags & GraphUtils.DIRECTED_MASK) == 0) { if (LOGGER.isDebugEnabled()) { LOGGER.debug(" " + instanceString + ".edges() returning all undirected edges"); } return new AnyToAnyEdgeCollection(GraphUtils.UNDIRECTED_EDGE_PREDICATE, BASE_TAIL_UNDIRECTED_CURSOR_FILTER); } else { if (LOGGER.isDebugEnabled()) { LOGGER.debug(" " + instanceString + ".edges() returning all edges"); } return edgeCollection; } } if (LOGGER.isDebugEnabled()) { LOGGER.debug(" " + instanceString + ".edges() returning general filtered collection"); } return new AnyToAnyEdgeCollection(edgePredicate, new AnyToAnyCursorFilter(directionFlags, userPredicate)); } // If we reach this point, at least one node is of // PredicateSpec.PREDICATE // Make sure A is a predicate if (nodeAType == PredicateSpec.ANY) { nodeA = nodeB; nodeB = TruePredicate.INSTANCE; nodeBType = PredicateSpec.ANY; directionFlags = GraphUtils.invertDirection(directionFlags); } Predicate basePredicate = (Predicate) nodeA; if (nodeBType == PredicateSpec.ANY) { if (LOGGER.isDebugEnabled()) { LOGGER.debug(" " + instanceString + ".edges() returning optimized filtered collection"); } return new PredToAnyEdgeCollection(edgePredicate, basePredicate, new PredToAnyCursorFilter(directionFlags, basePredicate, userPredicate)); } // First is P~Q, Q(base) true. // Second is P~Q, Q(base) false. CursorFilter qFilter = new PQToQCursorFilter(directionFlags, basePredicate, (Predicate) nodeB, userPredicate); CursorFilter notQFilter = new ToPredCursorFilter(directionFlags, (Predicate) nodeB, userPredicate); if (LOGGER.isDebugEnabled()) { LOGGER.debug(" " + instanceString + ".edges() returning optimized filtered collection"); } return new PToQEdgeCollection(edgePredicate, basePredicate, (Predicate) nodeB, qFilter, notQFilter); }
From source file:org.lockss.crawler.TestFollowLinkCrawler.java
public void testCrawlTestCrawlFail() throws Exception { crawler.setDaemonPermissionCheckers(ListUtil.list(new MyMockPermissionChecker(0))); testAbbreviatedCrawlTest(Crawler.STATUS_NO_PUB_PERMISSION, State.Unknown, Collections.EMPTY_SET, 1, ListUtil.list("html"), null, ListUtil.list(nsurl1, nsurl2, nsurl3, nsurl4)); }
From source file:org.webcurator.domain.TargetDAOImpl.java
@SuppressWarnings("unchecked") public Set<Long> getAncestorOids(final Long childOid) { if (childOid == null) { return Collections.EMPTY_SET; } else {//from w w w. j a v a2 s . c o m Set<Long> parentOids = new HashSet<Long>(); List<Long> immediateParents = getHibernateTemplate().executeFind(new HibernateCallback() { public Object doInHibernate(Session aSession) throws HibernateException, SQLException { //Criteria q = aSession.createCriteria("new java.lang.Long(oid) FROM TargetGroup").createCriteria("children").add(Restrictions.eq("oid", childOid)); Query q = aSession.createQuery( "SELECT new java.lang.Long(gm.parent.oid) FROM GroupMember gm where gm.child.oid = :childOid"); q.setLong("childOid", childOid); return q.list(); } }); for (Long parentOid : immediateParents) { parentOids.add(parentOid); parentOids.addAll(getAncestorOids(parentOid)); } return parentOids; } }
From source file:org.webcurator.domain.TargetDAOImpl.java
@SuppressWarnings("unchecked") public Set<AbstractTargetDTO> getAncestorDTOs(final Long childOid) { if (childOid == null) { return Collections.EMPTY_SET; } else {//from w w w . j a v a 2s . c o m Set<AbstractTargetDTO> parents = new HashSet<AbstractTargetDTO>(); List<AbstractTargetDTO> immediateParents = getHibernateTemplate().executeFind(new HibernateCallback() { public Object doInHibernate(Session aSession) throws HibernateException, SQLException { // Criteria c = aSession.createCriteria("new org.webcurator.domain.model.dto.AbstractTargetDTO(t.oid, t.name, t.owner.oid, t.owner.username, t.owner.agency.name, t.state, t.profile.oid, t.objectType)", "TargetGroup"); // c.createCriteria("children").createCriteria("child").add(Restrictions.eq("oid", childOid)); // return c.list(); Query q = aSession.createQuery( "SELECT new org.webcurator.domain.model.dto.AbstractTargetDTO(t.oid, t.name, t.owner.oid, t.owner.username, t.owner.agency.name, t.state, t.profile.oid, t.objectType) FROM TargetGroup t LEFT JOIN t.children AS gm INNER JOIN gm.child AS child where child.oid = :childOid"); q.setLong("childOid", childOid); return q.list(); } }); for (AbstractTargetDTO parent : immediateParents) { parents.add(parent); parents.addAll(getAncestorDTOs(parent.getOid())); } return parents; } }
From source file:com.sugaronrest.restapicalls.SugarRestClientExt.java
public static <T> Set<T> safeSet(Set<T> other) { return other == null ? Collections.EMPTY_SET : other; }
From source file:org.webcurator.domain.TargetDAOImpl.java
@SuppressWarnings("unchecked") public Set<Long> getImmediateChildrenOids(final Long parentOid) { if (parentOid == null) { return Collections.EMPTY_SET; } else {/*from w w w. j a v a2s . c om*/ List<Long> immediateChildren = getHibernateTemplate().executeFind(new HibernateCallback() { public Object doInHibernate(Session aSession) throws HibernateException, SQLException { //Criteria q = aSession.createCriteria("new java.lang.Long(oid) FROM TargetGroup").createCriteria("children").add(Restrictions.eq("oid", childOid)); Query q = aSession.createQuery( "SELECT new java.lang.Long(gm.child.oid) FROM GroupMember gm where gm.parent.oid = :parentOid"); q.setLong("parentOid", parentOid); return q.list(); } }); Set<Long> retval = new HashSet<Long>(); retval.addAll(immediateChildren); return retval; } }
From source file:com.phoenixst.plexus.DefaultGraph.java
public Collection edges(Predicate edgePredicate) { if (LOGGER.isDebugEnabled()) { LOGGER.debug(instanceString + ".edges( " + edgePredicate + " )"); }/*from w ww .j av a2 s . c o m*/ if (edgePredicate == null || edgePredicate == TruePredicate.INSTANCE) { if (LOGGER.isDebugEnabled()) { LOGGER.debug(" " + instanceString + ".edges() returning all edges"); } return edgeCollection; } else if (edgePredicate == FalsePredicate.INSTANCE) { if (LOGGER.isDebugEnabled()) { LOGGER.debug(" " + instanceString + ".edges() returning empty set"); } return Collections.EMPTY_SET; } else if (edgePredicate == GraphUtils.DIRECTED_EDGE_PREDICATE) { if (LOGGER.isDebugEnabled()) { LOGGER.debug(" " + instanceString + ".edges() returning all directed edges"); } return new AnyToAnyEdgeCollection(GraphUtils.DIRECTED_EDGE_PREDICATE, BASE_TAIL_DIRECTED_CURSOR_FILTER); } else if (edgePredicate == GraphUtils.UNDIRECTED_EDGE_PREDICATE) { if (LOGGER.isDebugEnabled()) { LOGGER.debug(" " + instanceString + ".edges() returning all undirected edges"); } return new AnyToAnyEdgeCollection(GraphUtils.UNDIRECTED_EDGE_PREDICATE, BASE_TAIL_UNDIRECTED_CURSOR_FILTER); } else if (edgePredicate == GraphUtils.SELF_EDGE_PREDICATE) { if (LOGGER.isDebugEnabled()) { LOGGER.debug(" " + instanceString + ".edges() returning all self edges"); } return new AnyToAnyEdgeCollection(GraphUtils.SELF_EDGE_PREDICATE, SELF_CURSOR_FILTER); } else if (edgePredicate instanceof EdgePredicate) { return edgesHelper((EdgePredicate) edgePredicate); } else if (edgePredicate instanceof EqualPredicate) { Graph.Edge testEdge = (Graph.Edge) ((EqualPredicate) edgePredicate).getTestObject(); if (!containsEdge(testEdge)) { if (LOGGER.isDebugEnabled()) { LOGGER.debug(" " + instanceString + ".edges() returning empty set"); } return Collections.EMPTY_SET; } if (LOGGER.isDebugEnabled()) { LOGGER.debug(" " + instanceString + ".edges() returning singleton"); } return new SingletonEdgeCollection(this, testEdge); } else { if (LOGGER.isDebugEnabled()) { LOGGER.debug(" " + instanceString + ".edges() returning general filtered collection"); } return new AnyToAnyEdgeCollection(edgePredicate, new BTailCursorFilter(edgePredicate)); } }
From source file:org.hyperledger.fabric.sdk.NetworkConfig.java
/** * Get the channel names found.//from ww w . ja v a 2 s. c o m * * @return A set of the channel names found in the configuration file or empty set if none found. */ public Set<String> getChannelNames() { Set<String> ret = Collections.EMPTY_SET; JsonObject channels = getJsonObject(jsonConfig, "channels"); if (channels != null) { final Set<String> channelNames = channels.keySet(); if (channelNames != null && !channelNames.isEmpty()) { ret = new HashSet<>(channelNames); } } return ret; }