List of usage examples for java.util Collections singleton
public static <T> Set<T> singleton(T o)
From source file:com.hortonworks.streamline.streams.runtime.splitjoin.SplitJoinTest.java
@Test public void testSplitJoinProcessorsWithActionsHavingStreams() throws Exception { String[] outputStreams = { "stream-1", "stream-2", "stream-3" }; final SplitAction splitAction = new SplitAction(); splitAction.setOutputStreams(Sets.newHashSet(outputStreams)); final JoinAction joinAction = new JoinAction(); joinAction.setOutputStreams(Collections.singleton("output-stream")); runSplitJoin(splitAction, joinAction); }
From source file:com.cloudmine.api.db.BaseLocallySavableCMObject.java
@Expand(isStatic = true) public static CloudMineRequest loadObject(Context context, String objectId, @Optional CMSessionToken token, @Optional CMApiCredentials apiCredentials, @Optional CMServerFunction serverFunction, @Optional Response.Listener<CMObjectResponse> listener, @Optional Response.ErrorListener errorListener) { return loadObjects(context, Collections.singleton(objectId), token, apiCredentials, serverFunction, listener, errorListener);/*from w w w. j a v a2 s. co m*/ }
From source file:com.griddynamics.jagger.engine.e1.reporting.MetricPlotsReporter.java
@Override public JRDataSource getDataSource(String testId) { if (plots == null) { plots = createTaskPlots();// w w w . ja va 2 s. co m } return new JRBeanCollectionDataSource(Collections.singleton(plots.get(testId))); }
From source file:org.wallride.autoconfigure.WebGuestComponentScanRegistrar.java
private Set<String> getPackagesToScan(AnnotationMetadata metadata) { AnnotationAttributes attributes = AnnotationAttributes .fromMap(metadata.getAnnotationAttributes(WebGuestComponentScan.class.getName())); String[] value = attributes.getStringArray("value"); String[] basePackages = attributes.getStringArray("basePackages"); Class<?>[] basePackageClasses = attributes.getClassArray("basePackageClasses"); if (!ObjectUtils.isEmpty(value)) { Assert.state(ObjectUtils.isEmpty(basePackages), "@WebGuestComponentScan basePackages and value attributes are mutually exclusive"); }//from www . ja va 2 s . c o m Set<String> packagesToScan = new LinkedHashSet<String>(); packagesToScan.addAll(Arrays.asList(value)); packagesToScan.addAll(Arrays.asList(basePackages)); for (Class<?> basePackageClass : basePackageClasses) { packagesToScan.add(ClassUtils.getPackageName(basePackageClass)); } if (packagesToScan.isEmpty()) { return Collections.singleton(ClassUtils.getPackageName(metadata.getClassName())); } return packagesToScan; }
From source file:io.pivotal.strepsirrhini.chaoslemur.infrastructure.InfrastructureConfiguration.java
@Bean @ConditionalOnProperty("openstack.endpoint") NovaApi novaApi(@Value("${openstack.endpoint}") String endpoint, @Value("${openstack.tenant}") String tenant, @Value("${openstack.username}") String username, @Value("${openstack.password}") String password) { String identity = String.format("%s:%s", tenant, username); // see https://issues.apache.org/jira/browse/JCLOUDS-816 Properties overrides = new Properties(); overrides.put(Constants.PROPERTY_TRUST_ALL_CERTS, "true"); overrides.put(Constants.PROPERTY_RELAX_HOSTNAME, "true"); return ContextBuilder.newBuilder("openstack-nova").endpoint(endpoint).credentials(identity, password) .modules(Collections.singleton(new SLF4JLoggingModule())).overrides(overrides) .buildApi(NovaApi.class); }
From source file:com.phoenixst.plexus.algorithms.DepthFirstTreeView.java
public Collection rootNodes() { return Collections.singleton(startNode); }
From source file:de.hybris.platform.catalog.jalo.synchronization.ItemCopyCreatorServiceLayerTest.java
private <T extends ItemModel> T createCreateConstraint(final String pattern) { final PatternConstraintModel constraint = modelService.create(PatternConstraintModel.class); constraint.setId("failOnCreate"); constraint.setDescriptor(typeService.getAttributeDescriptor(ProductModel._TYPECODE, ProductModel.CODE)); constraint.setType(typeService.getComposedTypeForClass(ProductModel.class)); constraint.setRegexp(pattern);//from www . j a va 2 s .c om constraint.setFlags(Collections.singleton(RegexpFlag.DOTALL)); return (T) constraint; }
From source file:org.commonjava.aprox.depgraph.rest.ResolverController.java
public String resolveGraph(final String from, final String groupId, final String artifactId, final String version, final boolean recurse, final String workspaceId, final Map<String, String[]> params) throws AproxWorkflowException { URI source;/*from w w w. j a v a 2 s . c o m*/ try { source = sourceManager.createSourceURI(from); } catch (final CartoDataException e) { throw new AproxWorkflowException("Invalid source specification: {}. Reason: {}", e, from, e.getMessage()); } if (source == null) { final String message = String.format("Invalid source format: '%s'. Use the form: '%s' instead.", from, sourceManager.getFormatHint()); logger.warn(message); throw new AproxWorkflowException(ApplicationStatus.BAD_REQUEST.code(), message); } final ProjectVersionRef ref = new ProjectVersionRef(groupId, artifactId, version); final AggregationOptions options = createAggregationOptions(params, source); Set<ProjectVersionRef> resolved; ViewParams resolvedParams = null; try { resolvedParams = ops.resolve(workspaceId, options, ref); resolved = resolvedParams.getRoots(); if (resolved == null || resolved.isEmpty()) { resolved = Collections.singleton(ref); } return serializer.writeValueAsString(Collections.singletonMap("resolvedTopLevelGAVs", resolved)); } catch (final CartoDataException e) { throw new AproxWorkflowException("Failed to resolve graph: {} from: {}. Reason: {}", e, ref, from, e.getMessage()); } catch (final JsonProcessingException e) { throw new AproxWorkflowException("Failed to serialize to JSON: %s", e, e.getMessage()); } }
From source file:com.devicehive.service.NetworkService.java
@Transactional(propagation = Propagation.NOT_SUPPORTED) public NetworkWithUsersAndDevicesVO getWithDevicesAndDeviceClasses(@NotNull Long networkId, @NotNull HiveAuthentication hiveAuthentication) { HivePrincipal principal = (HivePrincipal) hiveAuthentication.getPrincipal(); Set<Long> permittedNetworks = principal.getNetworkIds(); Set<String> permittedDevices = principal.getDeviceGuids(); Optional<NetworkWithUsersAndDevicesVO> result = of(principal).flatMap(pr -> { if (pr.getUser() != null) return of(pr.getUser()); else//from w w w .ja v a 2 s . co m return empty(); }).flatMap(user -> { Long idForFiltering = user.isAdmin() ? null : user.getId(); List<NetworkWithUsersAndDevicesVO> found = networkDao.getNetworksByIdsAndUsers(idForFiltering, Collections.singleton(networkId), permittedNetworks); return found.stream().findFirst(); }).map(network -> { //fixme - important, restore functionality once permission evaluator is switched to jwt /*if (principal.getKey() != null) { Set<AccessKeyPermissionVO> permissions = principal.getKey().getPermissions(); Set<AccessKeyPermissionVO> filtered = CheckPermissionsHelper .filterPermissions(principal.getKey(), permissions, AccessKeyAction.GET_DEVICE, details.getClientInetAddress(), details.getOrigin()); if (filtered.isEmpty()) { network.setDevices(Collections.emptySet()); } }*/ if (permittedDevices != null && !permittedDevices.isEmpty()) { Set<DeviceVO> allowed = network.getDevices().stream() .filter(device -> permittedDevices.contains(device.getGuid())).collect(Collectors.toSet()); network.setDevices(allowed); } return network; }); return result.orElse(null); }
From source file:com._4dconcept.springframework.data.marklogic.repository.config.MarklogicRepositoryConfigurationExtension.java
@Override protected Collection<Class<? extends Annotation>> getIdentifyingAnnotations() { return Collections.singleton(Document.class); }