List of usage examples for java.util Collections singletonList
public static <T> List<T> singletonList(T o)
From source file:Fetch5.java
public Map<String, List<String>> get(URI uri, Map<String, List<String>> requestHeaders) throws IOException { StringBuilder cookies = new StringBuilder(); for (Cookie cookie : cookieJar) { // Remove cookies that have expired if (cookie.hasExpired()) { cookieJar.remove(cookie);//from w ww . j a v a2s.co m } else if (cookie.matches(uri)) { if (cookies.length() > 0) { cookies.append(", "); } cookies.append(cookie.toString()); } } Map<String, List<String>> cookieMap = new HashMap<String, List<String>>(requestHeaders); if (cookies.length() > 0) { List<String> list = Collections.singletonList(cookies.toString()); cookieMap.put("Cookie", list); } System.out.println("CookieMap: " + cookieMap); return Collections.unmodifiableMap(cookieMap); }
From source file:de.tud.inf.db.sparqlytics.olap.SliceTest.java
@Test public void testRun() { Expr value = NodeValue.TRUE;/*from w w w . j a v a 2s . co m*/ Slice instance = new Slice("dim1", "lev1", value); Session session = new Session(); CubeBuilder builder = new CubeBuilder(new ElementTriplesBlock(BasicPattern.wrap( Collections.singletonList(Triple.createMatch(NodeFactory.createVariable("test"), null, null))))) .addMeasure(new DummyMeasure("mes1")); Dimension dim1 = new DummyDimension("dim1"); Level lev1 = dim1.getLevels().get(0); session.setCube(builder.addDimension(dim1).build("")); session.execute(instance); Map<Pair<Dimension, Level>, Filter> filters = session.getFilters(); Assert.assertEquals(1, filters.size()); Map.Entry<Pair<Dimension, Level>, Filter> entry = filters.entrySet().iterator().next(); Pair<Dimension, Level> key = entry.getKey(); Assert.assertSame(dim1, key.getLeft()); Assert.assertSame(lev1, key.getRight()); Expr predicate = entry.getValue().getPredicate(); Assert.assertTrue(predicate instanceof E_Equals); Assert.assertSame(value, ((E_Equals) predicate).getArg2()); }
From source file:com.photon.phresco.service.admin.actions.components.PilotProjects.java
public String save() { S_LOGGER.debug("Entering Method PilotProjects.save()"); try {//from ww w . j a v a2s . c o m if (validateForm()) { setErrorFound(true); return SUCCESS; } InputStream inputStream = new FileInputStream(projArc); /* FileOutputStream outputStream = new FileOutputStream(new File("c:/" + projArcFileName)); IOUtils.copy(inputStream, outputStream);*/ addActionMessage(getText(PLTPROJ_ADDED, Collections.singletonList(name))); } catch (Exception e) { addActionError(getText(PLTPROJ_NOT_ADDED, Collections.singletonList(name))); } return COMP_PILOTPROJ_LIST; }
From source file:com.hp.autonomy.aci.content.fieldtext.EQUALALL.java
/** * Constructs a new single field EQUALALL fieldtext * @param field The field name// ww w . j a v a 2 s.c o m * @param values The field values */ public EQUALALL(final String field, final Iterable<? extends Number> values) { this(Collections.singletonList(field), values); }
From source file:de.hybris.platform.integration.cis.tax.strategies.impl.DefaultCisCalculateExternalTaxesFallbackStrategyTest.java
@Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); defaultCisCalculateExternalTaxesFallbackStrategy = new DefaultCisCalculateExternalTaxesFallbackStrategy(); defaultCisCalculateExternalTaxesFallbackStrategy.setConfigurationService(configurationService); given(configuration.getBigDecimal("cistax.taxCalculation.fallback.fixedpercentage", BigDecimal.valueOf(0D))) .willReturn(BigDecimal.valueOf(9.70d)); given(configurationService.getConfiguration()).willReturn(configuration); final CurrencyModel currencyModel = mock(CurrencyModel.class); final AbstractOrderEntryModel entry = mock(AbstractOrderEntryModel.class); given(currencyModel.getIsocode()).willReturn("USD"); given(abstractOrder.getCurrency()).willReturn(currencyModel); given(abstractOrder.getEntries()).willReturn(Collections.singletonList(entry)); given(entry.getTotalPrice()).willReturn(Double.valueOf(100D)); given(abstractOrder.getDeliveryCost()).willReturn(Double.valueOf(9.9D)); }
From source file:org.deegree.securityproxy.authentication.header.HeaderTokenAuthenticationManager.java
public HeaderTokenAuthenticationManager(AuthenticationProvider authenticationProvider) { super(Collections.singletonList(authenticationProvider)); }
From source file:org.traccar.api.AsyncSocket.java
@Override public void onUpdatePosition(Position position) { Map<String, Collection<?>> data = new HashMap<>(); data.put(KEY_POSITIONS, Collections.singletonList(position)); sendData(data);//from www .j a va 2s . com }
From source file:cz.muni.fi.pa165.rentalofconstructionmachineryweb.controller.MachineController.java
@RequestMapping(value = "/{id}/details", method = RequestMethod.GET) public String getDetails(@PathVariable Long id, Model model) { if (null == id) { return "redirect:/machine?error&msg=Machine Id not provided"; } else {/*from w w w . j av a 2 s .c om*/ MachineDTO machine = machineService.searchForMachineById(id); if (null == machine) { return "redirect:/machine?error&msg=Machine with given Id doesn't exist"; } else { model.addAttribute("machine", machine); List<RentalDTO> rentals = rentalService.getRentalsByMachine(machine); model.addAttribute("rentals", rentals); List<RevisionDTO> revisions = revisionService.getAllRevisionsOfMachine(machine); model.addAttribute("revisions", revisions); if (0 != revisions.size()) { RevisionDTO lastRevision = revisionService.getLastRevisionOfMachine(machine); model.addAttribute("lastRevision", Collections.singletonList(lastRevision)); } else { model.addAttribute("lastRevision", null); } return "machineDetails"; } } }
From source file:com.hp.autonomy.aci.content.fieldtext.NOTEQUAL.java
/** * Constructs a new single field NOTEQUAL fieldtext * @param field The field name// w w w . j av a2 s .c om * @param values The field values */ public NOTEQUAL(final String field, final Iterable<? extends Number> values) { this(Collections.singletonList(field), values); }
From source file:dlauncher.modpacks.download.ModPackListingVanilla.java
@Override public Collection<? extends UnresolvedModPack> readModPacksFromResource(byte[] resourceBytes) throws IOException { JSONObject json = new JSONObject(new String(resourceBytes, Charset.forName("UTF-8"))); final DefaultModPack modpack = new DefaultModPack("Vanilla", Arrays.asList("Mojang AB"), null, "This is the vanilla minecraft", null, new DefaultDownloadLocation(this.getClass().getResource("/images/TEMP_Vanilla.png")), new URL("https://minecraft.net/")); UnresolvedModPack unresolved = new UnresolvedModPack() { @Override//from www .j a va 2 s .co m public Collection<? extends ModPackVersionDescription> getRequiredDependencies() { return Collections.emptyList(); } @Override public ModPack createModPack(Map<String, ModPack> dependencies) { return modpack; } @Override public String getName() { return modpack.getName(); } }; JSONArray versions = json.getJSONArray("versions"); for (int i = 0; i < versions.length(); i++) modpack.addModPackVersion(new VanillaModPackVersion(versions.getJSONObject(i), modpack)); return Collections.singletonList(unresolved); }