List of usage examples for java.util Collections emptySet
@SuppressWarnings("unchecked") public static final <T> Set<T> emptySet()
From source file:de.tudarmstadt.ukp.dkpro.lexsemresource.wikipedia.WikipediaArticleResource.java
public Set<Entity> getParents(Entity entity) throws LexicalSemanticResourceException { if (!this.containsEntity(entity)) { return Collections.emptySet(); }//from www. j a va 2s. co m Page p = WikipediaArticleUtils.entityToPage(wiki, entity, isCaseSensitive); return WikipediaArticleUtils.pagesToEntities(wiki, p.getInlinks(), isCaseSensitive); }
From source file:ai.grakn.graql.internal.analytics.MedianVertexProgram.java
@Override public Set<MessageScope> getMessageScopes(final Memory memory) { switch (memory.getIteration()) { case 0:/*from w w w. j a v a 2 s.co m*/ return Collections.singleton(messageScopeShortcutIn); case 1: return Collections.singleton(messageScopeShortcutOut); default: return Collections.emptySet(); } }
From source file:com.ge.predix.test.utils.PolicyHelper.java
public PolicyEvaluationRequestV1 createRandomEvalRequest() { Random r = new Random(System.currentTimeMillis()); Set<Attribute> subjectAttributes = Collections.emptySet(); return this.createEvalRequest(ACTIONS[r.nextInt(4)], String.valueOf(r.nextLong()), "/alarms/sites/" + String.valueOf(r.nextLong()), subjectAttributes); }
From source file:com.wms.studio.cache.lock.SyncLockMapCache.java
@Override public Set<K> keys() { try {/*from w ww. j ava 2 s . c om*/ HashMap<K, V> attributes = memcachedClient.get(name); if (attributes != null) { Set<K> keys = attributes.keySet(); if (!keys.isEmpty()) return Collections.unmodifiableSet(keys); } } catch (Exception e) { log.fatal("?MemCache,.", e); } return Collections.emptySet(); }
From source file:com.ge.predix.acs.service.policy.evaluation.PolicyEvaluationWithAttributeUriTemplateTest.java
@Test public void testEvaluateWithURIAttributeTemplate() throws JsonParseException, JsonMappingException, IOException { MockitoAnnotations.initMocks(this); Whitebox.setInternalState(this.policyMatcher, "attributeReaderFactory", this.attributeReaderFactory); Whitebox.setInternalState(this.evaluationService, "policyMatcher", this.policyMatcher); when(this.zoneResolver.getZoneEntityOrFail()).thenReturn(new ZoneEntity(0L, "testzone")); when(this.cache.get(any(PolicyEvaluationRequestCacheKey.class))).thenReturn(null); when(this.attributeReaderFactory.getResourceAttributeReader()) .thenReturn(this.defaultResourceAttributeReader); when(this.attributeReaderFactory.getSubjectAttributeReader()) .thenReturn(this.defaultSubjectAttributeReader); // set policy PolicySet policySet = new ObjectMapper().readValue( new File("src/test/resources/policy-set-with-attribute-uri-template.json"), PolicySet.class); when(this.policyService.getAllPolicySets()).thenReturn(Arrays.asList(policySet)); // Create 'role' attribute in resource for URI /site/1234. Used in target match for policy 1. BaseResource testResource = new BaseResource("/site/1234"); Set<Attribute> resourceAttributes = new HashSet<>(); resourceAttributes.add(new Attribute("https://acs.attributes.int", "role", "admin")); testResource.setAttributes(resourceAttributes); when(this.defaultResourceAttributeReader.getAttributes(testResource.getResourceIdentifier())) .thenReturn(testResource.getAttributes()); BaseSubject testSubject = new BaseSubject("test-subject"); testSubject.setAttributes(Collections.emptySet()); when(this.defaultSubjectAttributeReader.getAttributesByScope(anyString(), anySetOf(Attribute.class))) .thenReturn(testSubject.getAttributes()); // resourceURI matches attributeURITemplate PolicyEvaluationResult evalResult = this.evaluationService .evalPolicy(createRequest("/v1/site/1234/asset/456", "test-subject", "GET")); Assert.assertEquals(evalResult.getEffect(), Effect.PERMIT); // resourceURI does NOT match attributeURITemplate evalResult = this.evaluationService .evalPolicy(createRequest("/v1/no-match/asset/123", "test-subject", "GET")); // second policy will match. Assert.assertEquals(evalResult.getEffect(), Effect.DENY); }
From source file:com.tesora.dve.mysqlapi.repl.MyReplicationSlaveConfig.java
public Set<String> getIgnoreTableList() { if (configFile == null) return Collections.emptySet(); if (ignoreTableList != null) return ignoreTableList; ignoreTableList = new HashSet<String>(Arrays.asList(configProps.getStringArray(REPL_IGNORE_TABLE_KEY))); return ignoreTableList; }
From source file:cop.raml.utils.Utils.java
/** * Convert enum constants in given {@code arr} to no duplication constant collection. * * @param arr array of enum items//from w ww. j a v a 2 s . c o m * @return {@code null} or not empty enum item set */ @NotNull public static Set<String> asSet(String... arr) { if (ArrayUtils.isEmpty(arr)) return Collections.emptySet(); return Arrays.stream(arr).filter(StringUtils::isNotBlank).map(String::trim) .collect(toCollection(LinkedHashSet::new)); }
From source file:cop.raml.utils.UtilsTest.java
@Test public void testGetParams() { assertThat(Utils.getParams(null)).isSameAs(Collections.emptySet()); assertThat(Utils.getParams("")).isSameAs(Collections.emptySet()); assertThat(Utils.getParams(" ")).isSameAs(Collections.emptySet()); assertThat(Utils.getParams("simple string")).isSameAs(Collections.emptySet()); assertThat(Utils.getParams("/project/{projectId}/order/{orderId}/validation")).containsExactly("projectId", "orderId"); }
From source file:de.tudarmstadt.ukp.dkpro.core.io.text.TokenizedTextWriter.java
@Override public void initialize(UimaContext context) throws ResourceInitializationException { super.initialize(context); getLogger().info("Writing to file " + getTargetLocation()); try {//from w ww. j a v a 2 s .co m targetWriter = new BufferedWriter( new OutputStreamWriter(new FileOutputStream(getTargetLocation()), targetEncoding)); stopwords = stopwordsFile == null ? Collections.emptySet() : readStopwordsFile(stopwordsFile); } catch (IOException e) { throw new ResourceInitializationException(e); } }
From source file:edu.toronto.cs.phenotips.measurements.MeasurementsScriptService.java
/** * Get the names of all the measurements handlers. * //from w ww . ja v a 2s .co m * @return a set with the names of all the measurement handlers, or an empty set if there was a problem retrieving * the actual values */ public Set<String> getAvailableMeasurementNames() { try { Map<String, MeasurementHandler> handlers = this.componentManager.get() .getInstanceMap(MeasurementHandler.class); if (handlers != null) { Set<String> result = new TreeSet<String>(MeasurementNameSorter.instance); result.addAll(handlers.keySet()); return result; } } catch (ComponentLookupException ex) { this.logger.warn("Failed to list available measurement types", ex); } return Collections.emptySet(); }