List of usage examples for java.util Collections singleton
public static <T> Set<T> singleton(T o)
From source file:com.google.gerrit.server.account.GeneratePassword.java
public AccountExternalId call() throws OrmException, NoSuchEntityException { AccountExternalId id = db.accountExternalIds().get(forUser); if (id == null || !user.getAccountId().equals(id.getAccountId())) { throw new NoSuchEntityException(); }/*from w w w . ja va 2s. co m*/ id.setPassword(generate()); db.accountExternalIds().update(Collections.singleton(id)); accountCache.evict(user.getAccountId()); return id; }
From source file:com.hp.autonomy.frontend.find.hod.fields.HodFieldsControllerTest.java
@Override protected HodFieldsRequest createRequest() { return new HodFieldsRequest.Builder().setDatabases(Collections.singleton(ResourceIdentifier.WIKI_ENG)) .build();/* w w w.j a v a2s .co m*/ }
From source file:com.opengamma.financial.analytics.model.bond.BondPV01CountryCurveFunction.java
@Override public Set<ValueSpecification> getResults(final FunctionCompilationContext context, final ComputationTarget target, final Map<ValueSpecification, ValueRequirement> inputs) { String curveName = null;//from w w w . j a v a 2 s . c o m for (ValueSpecification input : inputs.keySet()) { if (ValueRequirementNames.YIELD_CURVE.equals(input.getValueName())) { curveName = input.getProperty(ValuePropertyNames.CURVE); break; } } Validate.notNull(curveName, "curveName"); return Collections.singleton(new ValueSpecification(ValueRequirementNames.PV01, target.toSpecification(), createValueProperties().with(ValuePropertyNames.COUNTRY, BondFunctionUtils.getCountryName(target)) .with(ValuePropertyNames.CURVE, curveName).get())); }
From source file:com.opengamma.financial.analytics.model.bond.BondPV01CurrencyCurveFunction.java
@Override public Set<ValueSpecification> getResults(final FunctionCompilationContext context, final ComputationTarget target, final Map<ValueSpecification, ValueRequirement> inputs) { String curveName = null;/*from w w w . j a va 2 s . c om*/ for (ValueSpecification input : inputs.keySet()) { if (ValueRequirementNames.YIELD_CURVE.equals(input.getValueName())) { curveName = input.getProperty(ValuePropertyNames.CURVE); break; } } Validate.notNull(curveName, "curveName"); return Collections.singleton(new ValueSpecification(ValueRequirementNames.PV01, target.toSpecification(), createValueProperties().with(ValuePropertyNames.CURRENCY, BondFunctionUtils.getCurrencyName(target)) .with(ValuePropertyNames.CURVE, curveName).get())); }
From source file:de.codecentric.boot.admin.discovery.ApplicationDiscoveryListenerTest.java
@Test public void test_ignore() { when(discovery.getServices()).thenReturn(Collections.singletonList("service")); when(discovery.getInstances("service")).thenReturn(Collections .singletonList((ServiceInstance) new DefaultServiceInstance("service", "localhost", 80, false))); listener.setIgnoredServices(Collections.singleton("service")); listener.onInstanceRegistered(new InstanceRegisteredEvent<>(new Object(), null)); assertEquals(0, registry.getApplications().size()); }
From source file:com.datapine.service.impl.ItemServiceImplTest.java
/** * Before tests./*from w w w . j a v a 2 s . c om*/ */ @Before public final void before() { SecurityContextHolder.getContext().setAuthentication(new AnonymousAuthenticationToken("key", "test user", Collections.singleton(new SimpleGrantedAuthority("ROLE_USER")))); }
From source file:org.excalibur.service.deployment.server.context.handler.CreateNodeManagerHandler.java
@Override public void handlerApplicationInitializedEvent(Configuration configuration, ApplicationContext context, ServletContextEvent sce) {//w w w.j a va 2 s .c o m VirtualMachine thisNode = context.getBean(InstanceService.class) .getInstanceByName(configuration.getHostName()); ComputeService service = builder().credentials(configuration.getCredentials()) .provider(configuration.getCredentials().getProvider()).build(); if (thisNode == null) { thisNode = service.getInstanceWithName(configuration.getHostName(), configuration.getZone().getName()); } checkNotNull(thisNode, "Node %s not found on region/zone %s/%s of provider %s", configuration.getHostName(), configuration.getZone().getRegion(), configuration.getZone().getName()); context.getBean(InstanceService.class).insertOrUpdateInstances(Collections.singleton(thisNode)); NodeManager manager = new NodeManager(configuration, thisNode, service); this.configure(manager, context); NodeManagerFactory.setManager(manager); }
From source file:edu.cornell.mannlib.vitro.webapp.auth.identifier.common.CommonIdentifierBundleFactory.java
/** * If the user is logged in, create an identifier that shows his URI. *//*from ww w . j a v a 2 s . com*/ private Collection<? extends Identifier> createUserIdentifiers(HttpServletRequest req) { LoginStatusBean bean = LoginStatusBean.getBean(req); if (bean.isLoggedIn()) { return Collections.singleton(new IsUser(bean.getUserURI())); } else { return Collections.emptySet(); } }
From source file:dmh.kuebiko.view.ImageManagerTest.java
/** * Retrieve a list of all known image ID strings of a particular size. * @param size The size of the requested images. * @return A list of valid image IDs.// w ww .j av a2 s .c o m */ private Collection<String> getImageIds(ImageSize size) throws URISyntaxException { String path = String.format("images/%s/", size.toString().toLowerCase()); File imageDir = new File(getClass().getResource(path).toURI()); Collection<String> imageIds = Lists.newArrayList( Collections2.transform(Arrays.asList(imageDir.list()), new Function<String, String>() { @Override public String apply(String input) { return "png".equals(FilenameUtils.getExtension(input)) ? FilenameUtils.removeExtension(input) : ""; } })); imageIds.removeAll(Collections.singleton("")); return imageIds; }
From source file:io.kodokojo.service.aws.Route53DnsManager.java
@Override public boolean createOrUpdateDnsEntry(DnsEntry dnsEntry) { if (dnsEntry == null) { throw new IllegalArgumentException("dnsEntry must be defined."); }//from w ww . j ava 2 s .com createOrUpdateDnsEntries(Collections.singleton(dnsEntry)); return true; }