Example usage for java.util Arrays stream

List of usage examples for java.util Arrays stream

Introduction

In this page you can find the example usage for java.util Arrays stream.

Prototype

public static DoubleStream stream(double[] array) 

Source Link

Document

Returns a sequential DoubleStream with the specified array as its source.

Usage

From source file:io.knotx.adapter.common.placeholders.RequestPlaceholderSubstitutor.java

@Override
public String getValue(final ClientRequest request, final String placeholder) {
    return Arrays.stream(Strategy.values())
            .filter(strategy -> StringUtils.startsWith(placeholder, strategy.prefix)).findFirst()
            .map(strategy -> strategy.getValue(request, placeholder)).orElse(null);
}

From source file:com.haulmont.cuba.core.sys.AvailableLocalesFactory.java

@Override
public Object build(String string) {
    if (string == null)
        return null;

    return Arrays.stream(string.split(";")).map(item -> item.split("\\|"))
            .collect(Collectors.toMap(parts -> parts[0], parts -> LocaleUtils.toLocale(parts[1])));
}

From source file:com.github.blindpirate.gogradle.util.StringUtils.java

public static boolean allBlank(String... strs) {
    return Arrays.stream(strs).allMatch(StringUtils::isBlank);
}

From source file:com.thinkbiganalytics.util.PartitionKey.java

public static PartitionKey[] partitionKeysForTableAlias(PartitionKey[] keys, String alias) {
    List<PartitionKey> partitionKeys = new ArrayList<>();

    Arrays.stream(keys).forEach(key -> {
        try {//from  www  .j  a v a2s  .co  m
            PartitionKey clonedKey = (PartitionKey) key.clone();
            clonedKey.setAlias(alias);
            partitionKeys.add(clonedKey);
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
    });
    return partitionKeys.toArray(new PartitionKey[0]);
}

From source file:com.netflix.spinnaker.halyard.core.registry.v1.BillOfMaterials.java

static private <T> String getFieldVersion(Class<T> clazz, T obj, String artifactName) {
    Optional<Field> field = Arrays.stream(clazz.getDeclaredFields()).filter(f -> {
        boolean nameMatches = f.getName().equals(artifactName);
        boolean propertyMatches = false;
        JsonProperty property = f.getDeclaredAnnotation(JsonProperty.class);
        if (property != null) {
            propertyMatches = property.value().equals(artifactName);
        }//w  w w .j av  a 2s .  c om
        return nameMatches || propertyMatches;
    }).findFirst();

    try {
        return ((Artifact) field.orElseThrow(() -> new NoKnownArtifact(artifactName)).get(obj)).getVersion();
    } catch (IllegalAccessException e) {
        throw new RuntimeException(e);
    } catch (NullPointerException e) {
        throw new RuntimeException("Versioned artifact " + artifactName + " is not listed in the BOM");
    }
}

From source file:net.minecraftforge.oredict.DyeUtils.java

/**
 * Get the dye metadata from the stack, which can be passed into {@link EnumDyeColor#byMetadata(int)}.
 * @param stack the item stack/*w w  w .  ja  v a2  s  .  c  o  m*/
 * @return an {@link OptionalInt} holding the dye metadata for a dye, or an empty {@link OptionalInt} otherwise
 */
public static OptionalInt metaFromStack(ItemStack stack) {
    if (stack.isEmpty())
        return OptionalInt.empty();
    return Arrays.stream(OreDictionary.getOreIDs(stack)).mapToObj(OreDictionary::getOreName)
            .mapToInt(name -> ArrayUtils.indexOf(dyeOredicts, name)).filter(id -> id >= 0).findFirst();
}

From source file:jterm.command.Dir.java

@Command(name = "ls", syntax = "ls [-f] [-h] [directory]")
public static void ls(List<String> options) {
    File[] files = new File(JTerm.currentDirectory).listFiles();
    if (files == null) {
        return;//  ww  w. j a  v  a2 s . com
    }

    JTerm.out.println(TextColor.INFO, "[Contents of \"" + JTerm.currentDirectory + "\"]");
    Arrays.stream(files).forEach(options.contains("-f") ? FULL_PRINTER : SIMPLE_PRINTER);
}

From source file:my.school.spring.beans.DataProviderPostProcessor.java

@Override
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {

    Arrays.stream(bean.getClass().getDeclaredFields()).forEach(f -> {
        CustomDataProvider annotation = f.getAnnotation(CustomDataProvider.class);
        if (annotation != null) {
            String seedValue = annotation.data();
            f.setAccessible(true);/*from  w ww .ja  va 2  s. c  om*/
            ReflectionUtils.setField(f, bean, seedValue);
        }
    });

    return bean;
}

From source file:co.runrightfast.vertx.orientdb.config.ServerResource.java

/**
 *
 * @param user user name/*w w  w  . jav  a 2  s.c  om*/
 * @param password user password
 * @param resources at least 1 is required
 * @return
 */
public static OServerUserConfiguration serverUserConfiguration(final String user, final String password,
        final ServerResource... resources) {
    checkArgument(isNotBlank(user), MUST_NOT_BE_BLANK, "user");
    checkArgument(isNotBlank(password), MUST_NOT_BE_BLANK, "password");
    checkArgument(ArrayUtils.isNotEmpty(resources), MUST_NOT_BE_EMPTY, "resources");
    return new OServerUserConfiguration(user, password,
            Arrays.stream(resources).map(resource -> resource.resource).collect(Collectors.joining(",")));
}

From source file:com.github.braully.web.DescriptorExposedEntity.java

public DescriptorExposedEntity() {
    hiddenFormProperties = new HashSet<>();
    hiddenListProperties = new HashSet<>();
    hiddenFilterProperties = new HashSet<>();
    Arrays.stream(DEFAULT_HIDDEN_FILTER_FIELDS).forEach(s -> hiddenFilterProperties.add(s));
    Arrays.stream(DEFAULT_HIDDEN_FORM_FIELDS).forEach(s -> hiddenFormProperties.add(s));
}