List of usage examples for java.util Arrays stream
public static DoubleStream stream(double[] array)
From source file:delfos.rs.contentbased.vsm.booleanvsm.SparseVector.java
public static final <Key extends Comparable<Key>> SparseVector<Key> createFromPairs( Pair<Key, Double>... pairs) { SparseVector<Key> sparseVector = new SparseVector<>( Arrays.stream(pairs).map(entry -> entry.getKey()).collect(Collectors.toList())); Arrays.stream(pairs).forEach(pair -> sparseVector.map.put(pair.getKey(), pair.getValue())); return sparseVector; }
From source file:io.github.jeddict.jcode.util.PersistenceUtil.java
public static Optional<PersistenceUnit> getPersistenceUnit(Project project, String puName) { PUDataObject pud;// www . ja v a 2 s .co m try { pud = ProviderUtil.getPUDataObject(project); return Arrays.stream(pud.getPersistence().getPersistenceUnit()) .filter(persistenceUnit_In -> persistenceUnit_In.getName().equalsIgnoreCase(puName)) .findFirst(); } catch (InvalidPersistenceXmlException ex) { Exceptions.printStackTrace(ex); return Optional.empty(); } }
From source file:io.dfox.junit.http.util.TestUtils.java
/** * Convert the array of objects to a list of Strings by calling toString() on each. * * @param objects The objects to convert * @return The an array of strings//w ww .j a v a2 s.c o m */ public static ImmutableList<String> toStringList(final Object[] objects) { return Arrays.stream(objects).map(e -> e.toString()).collect(Collectors.toImmutableList()); }
From source file:com.netflix.spinnaker.halyard.config.model.v1.security.AuthnMethod.java
public static Class<? extends AuthnMethod> translateAuthnMethodName(String authnMethodName) { Optional<? extends Class<?>> res = Arrays.stream(Authn.class.getDeclaredFields()) .filter(f -> f.getName().equals(authnMethodName)).map(Field::getType).findFirst(); if (res.isPresent()) { return (Class<? extends AuthnMethod>) res.get(); } else {//from w w w. j a v a 2 s .c o m throw new IllegalArgumentException( "No authn method with name \"" + authnMethodName + "\" handled by halyard"); } }
From source file:co.runrightfast.vertx.core.eventbus.EventBusAddress.java
/** * Address format follows a URI path convention. * * e.g., eventBusAddress("path1","path2","path3") returns "/path1/path2/path3" * * * @param path REQUIRED/*from w ww . j a v a 2 s .c o m*/ * @param paths OPTIONAL * @return eventbus address */ public static String eventBusAddress(final String path, final String... paths) { checkArgument(isNotBlank(path)); final StringBuilder sb = new StringBuilder(128).append('/').append(path); if (ArrayUtils.isNotEmpty(paths)) { checkArgument(!Arrays.stream(paths).filter(StringUtils::isBlank).findFirst().isPresent()); sb.append('/').append(String.join("/", paths)); } return sb.toString(); }
From source file:iad.gui.HistogramDialog.java
/** * Creates new form HistogramDialog//from ww w . j a v a 2 s. com */ public HistogramDialog(java.awt.Frame parent, boolean modal, String klass, String param, Double[] data, int div) { super(parent, modal); double[] primitiveData = Arrays.stream(data).mapToDouble(Double::doubleValue).toArray(); JFreeChart histogram = buildHistogram(klass, "o X", "o Y", primitiveData, div, HistogramType.FREQUENCY); ChartPanel chartPanel = new ChartPanel(histogram); chartPanel.setPreferredSize(new Dimension(800, 600)); setContentPane(chartPanel); initComponents(); }
From source file:com.hurence.logisland.connect.opc.CommonUtils.java
/** * Extract structured info from tag properties. * * @param properties the tag properties given by the OPC connector * @return a list of {@link TagInfo}//from w w w.ja va 2 s . co m */ public static final List<TagInfo> parseTagsFromProperties(Map<String, String> properties) { List<String> tagIds = Arrays.asList(properties.get(CommonDefinitions.PROPERTY_TAGS_ID).split(",")); List<Duration> tagSamplings = Arrays .stream(properties.get(CommonDefinitions.PROPERTY_TAGS_SAMPLING_RATE).split(",")) .map(Duration::parse).collect(Collectors.toList()); List<StreamingMode> tagModes = Arrays .stream(properties.get(CommonDefinitions.PROPERTY_TAGS_STREAM_MODE).split(",")) .map(StreamingMode::valueOf).collect(Collectors.toList()); List<TagInfo> ret = new ArrayList<>(); for (int i = 0; i < tagIds.size(); i++) { ret.add(new TagInfo(tagIds.get(i), tagSamplings.get(i), tagModes.get(i))); } return ret; }
From source file:com.thoughtworks.go.config.rules.SupportedEntity.java
public static List<String> unmodifiableListOf(SupportedEntity... supportedEntities) { return unmodifiableList( Arrays.stream(supportedEntities).map(SupportedEntity::getType).collect(Collectors.toList())); }
From source file:co.runrightfast.vertx.core.eventbus.MessageHandler.java
/** * * @param <MSG> Message payload type * @param messageProcessor1 the first processor in the chain * @param messageProcessor2 the second processor in the chain * @param chain optional - the rest of the chain * @return handler/*from w w w. j a v a 2 s . co m*/ */ static <MSG extends com.google.protobuf.Message> Handler<Message<MSG>> composeHandler( @NonNull final MessageHandler<MSG> messageProcessor1, @NonNull final MessageHandler<MSG> messageProcessor2, final MessageHandler<MSG>... chain) { if (ArrayUtils.isEmpty(chain)) { return message -> messageProcessor1.andThen(messageProcessor2).apply(message); } final Function<Message<MSG>, Message<MSG>> composedProcessor = Arrays.stream(chain).sequential().reduce( messageProcessor1.andThen(messageProcessor2), (p1, p2) -> p1.andThen(p2), (p1, p2) -> p1.andThen(p2)); return message -> composedProcessor.apply(message); }
From source file:com.pablinchapin.planz.dailytaskmanager.client.service.TaskServiceBean.java
public List<TaskServiceDTO> findAll() { return Arrays.stream(restTemplate.getForObject(resource, TaskServiceDTO[].class)) .collect(Collectors.toList()); }