List of usage examples for java.util Collections singletonList
public static <T> List<T> singletonList(T o)
From source file:io.syndesis.verifier.AlwaysOkVerifier.java
@Override public List<Result> verify(String connectorId, Map<String, String> options) { return Collections.singletonList(ImmutableResult.builder().status(Result.Status.OK).build()); }
From source file:io.cloudslang.lang.compiler.modeller.transformers.ParallelLoopForTransformer.java
@Override public List<Scope> getScopes() { return Collections.singletonList(Scope.BEFORE_STEP); }
From source file:com.galenframework.ide.model.results.CommandExecutionResult.java
public static CommandExecutionResult error(Throwable ex) { CommandExecutionResult result = new CommandExecutionResult(); result.setStatus(ExecutionStatus.failed); result.setErrorMessages(/* www . j a v a 2s. co m*/ Collections.singletonList(ExceptionUtils.getMessage(ex) + "\n" + ExceptionUtils.getStackTrace(ex))); return result; }
From source file:io.pivotal.spring.cloud.service.eureka.EurekaServiceConnectorIntegrationTest.java
@BeforeClass public static void beforeClass() { Mockito.when(MockCloudConnector.instance.isInMatchingCloud()).thenReturn(true); Mockito.when(MockCloudConnector.instance.getServiceInfos()).thenReturn(Collections .singletonList(new EurekaServiceInfo("eureka", URI, CLIENT_ID, CLIENT_SECRET, ACCESS_TOKEN_URI))); }
From source file:org.openmrs.web.taglib.GlobalPropertyTag.java
public int doStartTag() { Object value;// www .j a v a 2 s. co m if (StringUtils.hasText(listSeparator)) { value = Collections.singletonList(defaultValue); } else { value = defaultValue; } if (StringUtils.hasText(listSeparator)) { String stringVal = (String) Context.getAdministrationService().getGlobalProperty(key, defaultValue); if (stringVal.trim().length() == 0) { value = Collections.emptyList(); } else { value = Arrays.asList(stringVal.split(listSeparator)); } } else { value = (String) Context.getAdministrationService().getGlobalProperty(key, defaultValue); } try { if (var != null) { pageContext.setAttribute(var, value); } else { pageContext.getOut().write(value.toString()); } } catch (Exception e) { log.error("error getting global property", e); } return SKIP_BODY; }
From source file:com.cloudera.oryx.ml.param.DiscreteAround.java
@Override public List<Integer> getTrialValues(int num) { Preconditions.checkArgument(num > 0); if (num == 1) { return Collections.singletonList(around); }/*w w w.j a v a 2 s .c o m*/ List<Integer> values = new ArrayList<>(num); int value = around - ((num - 1) * step / 2); for (int i = 0; i < num; i++) { values.add(value); value += step; } return values; }
From source file:com.consol.citrus.samples.flightbooking.FlightRouter.java
@Router public Collection<MessageChannel> determineTargetChannels(Message<?> message) { FlightBookingRequestMessage request = (FlightBookingRequestMessage) message.getPayload(); return Collections.singletonList(airlineMappings.get(request.getFlight().getAirline())); }
From source file:com.epam.reportportal.auth.AuthUtilsTest.java
@Test public void testAuthoritiesConverter() { Collection<GrantedAuthority> grantedAuthorities = Collections.singletonList(UserRole.USER).stream() .map(AuthUtils.AS_AUTHORITIES).collect(Collectors.toList()).get(0); Assert.assertThat("Incorrect authority conversion", grantedAuthorities.iterator().next().getAuthority(), Matchers.is(UserRole.USER.getAuthority())); }
From source file:com.act.analysis.similarity.SimilarityAnalysis.java
public static void main(String[] args) throws Exception { Options opts = new Options(); for (Option.Builder b : OPTION_BUILDERS) { opts.addOption(b.build());//from w ww .ja v a 2 s.c o m } CommandLine cl = null; try { CommandLineParser parser = new DefaultParser(); cl = parser.parse(opts, args); } catch (ParseException e) { System.err.format("Argument parsing failed: %s\n", e.getMessage()); HELP_FORMATTER.printHelp(LoadPlateCompositionIntoDB.class.getCanonicalName(), HELP_MESSAGE, opts, null, true); System.exit(1); } if (cl.hasOption("help")) { HELP_FORMATTER.printHelp(LoadPlateCompositionIntoDB.class.getCanonicalName(), HELP_MESSAGE, opts, null, true); return; } LicenseManager.setLicenseFile(cl.getOptionValue(OPTION_LICENSE_FILE)); if (cl.hasOption(OPTION_TARGET_INCHI) && cl.hasOption(OPTION_TARGET_FILE)) { System.err.format("Specify only one of -%s or -%s\n", OPTION_TARGET_INCHI, OPTION_TARGET_FILE); HELP_FORMATTER.printHelp(LoadPlateCompositionIntoDB.class.getCanonicalName(), HELP_MESSAGE, opts, null, true); System.exit(1); } List<SimilarityOperator> querySimilarityOperators = new ArrayList<>(); List<String> header = new ArrayList<>(); header.add("name"); header.add("id"); header.add("inchi"); if (cl.hasOption(OPTION_QUERY_INCHI) && !cl.hasOption(OPTION_QUERY_FILE)) { SimilarityOperator so = makeSimilarityOperators("from inchi", cl.getOptionValue(OPTION_QUERY_INCHI)); so.init(); querySimilarityOperators.add(so); header.addAll(so.getResultFields()); } else if (cl.hasOption(OPTION_QUERY_FILE) && !cl.hasOption(OPTION_QUERY_INCHI)) { TSVParser parser = new TSVParser(); parser.parse(new File(cl.getOptionValue(OPTION_QUERY_FILE))); for (Map<String, String> row : parser.getResults()) { System.out.format("Compiling query for %s, %s\n", row.get("name"), row.get("inchi")); SimilarityOperator so = makeSimilarityOperators(row.get("name"), row.get("inchi")); so.init(); querySimilarityOperators.add(so); header.addAll(so.getResultFields()); } } else { System.err.format("Specify exactly one of -%s or -%s\n", OPTION_QUERY_INCHI, OPTION_QUERY_FILE); HELP_FORMATTER.printHelp(LoadPlateCompositionIntoDB.class.getCanonicalName(), HELP_MESSAGE, opts, null, true); System.exit(1); } List<Map<String, String>> targetChemicals = null; if (cl.hasOption(OPTION_TARGET_INCHI) && !cl.hasOption(OPTION_TARGET_FILE)) { String inchi = cl.getOptionValue(OPTION_TARGET_INCHI); targetChemicals = Collections.singletonList(new HashMap<String, String>() { { put("name", "direct-input"); put("id", null); put("inchi", inchi); } }); } else if (cl.hasOption(OPTION_TARGET_FILE) && !cl.hasOption(OPTION_TARGET_INCHI)) { TSVParser parser = new TSVParser(); parser.parse(new File(cl.getOptionValue(OPTION_TARGET_FILE))); targetChemicals = parser.getResults(); } else { System.err.format("Specify exactly one of -%s or -%s\n", OPTION_TARGET_INCHI, OPTION_TARGET_FILE); HELP_FORMATTER.printHelp(LoadPlateCompositionIntoDB.class.getCanonicalName(), HELP_MESSAGE, opts, null, true); System.exit(1); } AlignmentMoleculeFactory alignmentMoleculeFactory = new AlignmentMoleculeFactory(); // TODO: add symmetric computations for target as query and each query as target. TSVWriter<String, String> writer = new TSVWriter<>(header); writer.open(new File(cl.getOptionValue(OPTION_OUTPUT_FILE))); try { for (Map<String, String> row : targetChemicals) { Molecule targetMol = MolImporter.importMol(row.get("inchi")); Cleaner.clean(targetMol, 3); // This will assign 3D atom coordinates to the MolAtoms in targetMol. Molecule targetFragment = findLargestFragment(targetMol.convertToFrags()); AlignmentMolecule am = alignmentMoleculeFactory.create(targetFragment, AlignmentProperties.DegreeOfFreedomType.TRANSLATE_ROTATE_FLEXIBLE); Map<String, String> outputRow = new HashMap<>(row); System.out.format("Processing target %s\n", row.get("name")); for (SimilarityOperator so : querySimilarityOperators) { System.out.format(" running query %s\n", so.getName()); Map<String, Double> results = so.calculateSimilarity(am); outputRow.putAll(doubleMapToStringMap(results)); } writer.append(outputRow); writer.flush(); } } finally { if (writer != null) { writer.close(); } } System.out.format("Done\n"); }
From source file:io.knotx.dataobjects.Fragment.java
public static Fragment raw(String data) { return new Fragment(Collections.singletonList(RAW_FRAGMENT_ID), data); }