List of usage examples for java.util Arrays stream
public static DoubleStream stream(double[] array)
From source file:io.knotx.adapter.common.placeholders.UriPlaceholderSubstitutor.java
@Override public String getValue(ClientRequest request, String placeholder) { return Arrays.stream(Strategy.values()) .filter(strategy -> StringUtils.startsWith(placeholder, strategy.prefix)).findFirst() .map(strategy -> strategy.getValue(request.getPath(), placeholder)).orElse(null); }
From source file:com.github.robozonky.internal.util.ToStringBuilder.java
private ToStringBuilder(final Object o, final String... excludeFields) { final String[] fieldExclusions = Stream.concat(Stream.of("password"), Arrays.stream(excludeFields)) .distinct().toArray(String[]::new); this.builder = new CustomReflectionToStringBuilder(o).setExcludeFieldNames(fieldExclusions); }
From source file:com.thoughtworks.go.server.cache.CacheKeyGenerator.java
public String generate(String identifier, Object... args) { final List<Object> allArgs = Arrays.stream(args).map(arg -> { if (isAllowed(arg)) { return arg; }//from w ww .j av a 2 s .c om throw new IllegalArgumentException("Type " + arg.getClass() + " is not allowed here!"); }).map(arg -> { if (arg instanceof CaseInsensitiveString) { return ((CaseInsensitiveString) arg).toLower(); } else { return arg; } }).collect(Collectors.toList()); allArgs.add(0, clazz.getName()); allArgs.add(1, identifier); return StringUtils.join(allArgs, DELIMITER).intern(); }
From source file:org.dataconservancy.packaging.tool.ser.SerializationAnnotationUtil.java
/** * Answers a {@code Map} of {@link PropertyDescriptor} instances, which are used to reflectively access the * {@link Serialize serializable} streams on {@code annotatedClass} instances. * <p>/*from w w w . j a va 2s . com*/ * Use of {@code PropertyDescriptor} is simply a convenience in lieu of the use of underlying Java reflection. * </p> * <p> * This method looks for fields annotated by the {@code Serialize} annotation on the {@code annotatedClass}. * A {@code PropertyDescriptor} is created for each field, and is keyed by the {@code StreamId} in the returned * {@code Map}. * </p> * * @param annotatedClass the class to scan for the presense of {@code @Serialize} * @return a Map of PropertyDescriptors keyed by their StreamId. */ public static Map<StreamId, PropertyDescriptor> getStreamDescriptors(Class annotatedClass) { HashMap<StreamId, PropertyDescriptor> results = new HashMap<>(); Arrays.stream(annotatedClass.getDeclaredFields()) .filter(candidateField -> AnnotationUtils.getAnnotation(candidateField, Serialize.class) != null) .forEach(annotatedField -> { AnnotationAttributes attributes = AnnotationUtils.getAnnotationAttributes(annotatedField, AnnotationUtils.getAnnotation(annotatedField, Serialize.class)); StreamId streamId = (StreamId) attributes.get("streamId"); PropertyDescriptor descriptor = BeanUtils.getPropertyDescriptor(PackageState.class, annotatedField.getName()); results.put(streamId, descriptor); }); return results; }
From source file:com.example.jpa.UserEntity.java
public static UserEntity of(final long id, final String signature, final String username, final String password, final Date createdAt, final Date updatedAt, final Authority... authorities) { final Set<Authority> authoritySet = Arrays.stream(authorities).collect(toSet()); return new UserEntity(id, signature, username, password, authoritySet, createdAt, updatedAt); }
From source file:cn.edu.zjnu.acm.judge.security.password.CombinePasswordEncoder.java
public CombinePasswordEncoder(int index, PasswordEncoder... passwordEncoders) { super(passwordEncoders[index]); PasswordEncoder[] clone = passwordEncoders.clone(); // null check Arrays.stream(clone).forEach(Objects::requireNonNull); encoders = clone;// w w w . j a va2 s . co m }
From source file:com.tekstosense.opennlp.config.ModelLoaderConfig.java
/** * Gets the models./*from w w w . java 2s . com*/ * * @return the models */ public static String[] getModels() { File dir = new File(Config.getConfiguration().getString(MODELPATH)); LOG.info("Loading Models from... " + dir.getAbsolutePath()); List<String> models = new ArrayList<>(); String[] modelNames = getModelNames(); List<String> wildCardPath = Arrays.stream(modelNames).map(model -> { return "en-ner-" + model + "*.bin"; }).collect(Collectors.toList()); FileFilter fileFilter = new WildcardFileFilter(wildCardPath, IOCase.INSENSITIVE); List<String> filePath = Arrays.asList(dir.listFiles(fileFilter)).stream() .map(file -> file.getAbsolutePath()).collect(Collectors.toList()); return filePath.toArray(new String[filePath.size()]); }
From source file:org.iti.agrimarket.view.FileUploadController.java
public String provideUploadInfo(Model model) { File rootFolder = new File( "C:\\Users\\Amr\\Documents\\GP\\Agri_Market\\agrimarket_gp_iti\\AgriMarket_v2.2"); List<String> fileNames = Arrays.stream(rootFolder.listFiles()).map(f -> f.getName()) .collect(Collectors.toList()); model.addAttribute("files", Arrays.stream(rootFolder.listFiles()).sorted(Comparator.comparingLong(f -> -1 * f.lastModified())) .map(f -> f.getName()).collect(Collectors.toList())); return "uploadForm"; }
From source file:io.github.jeddict.jcode.util.PersistenceUtil.java
public static void removeProperty(PersistenceUnit punit, String key) { if (punit.getProperties() != null || punit.getProperties().getProperty2() != null) { Arrays.stream(punit.getProperties().getProperty2()).filter(p1 -> StringUtils.equals(p1.getName(), key)) .findAny().ifPresent(p1 -> punit.getProperties().removeProperty2(p1)); }/*from w w w .j a v a 2 s.c o m*/ }
From source file:net.dempsy.distconfig.apahcevfs.Utils.java
public static FileObject getLatest(final FileObject parent) throws FileSystemException { try {//from www .jav a2s. co m final FileObject[] children = parent.getChildren(); if (children == null || children.length == 0) return null; return Arrays.stream(children).reduce(null, findLatest, findLatest); } catch (final FileNotFoundException | FileNotFolderException afnfe) { if (parent.exists()) throw afnfe; return null; } }