Example usage for java.util Set toArray

List of usage examples for java.util Set toArray

Introduction

In this page you can find the example usage for java.util Set toArray.

Prototype

<T> T[] toArray(T[] a);

Source Link

Document

Returns an array containing all of the elements in this set; the runtime type of the returned array is that of the specified array.

Usage

From source file:net.audumla.climate.ClimateDataFactory.java

/**
 * Replaces the climate data with a readonly version.
 *
 * @param cd the existing climate data bean
 * @return the climate data//from  w  w  w .ja v  a2s  .  c o  m
 */
public static ClimateData convertToReadOnlyClimateData(ClimateData cd) {
    if (cd == null) {
        return null;
    }
    Set<Class<?>> interfaces = new LinkedHashSet<Class<?>>();
    interfaces.addAll(ClassUtils.getAllInterfaces(cd.getClass()));
    interfaces.remove(WritableClimateData.class);
    return BeanUtils.convertBean(cd, interfaces.toArray(new Class<?>[interfaces.size()]));
}

From source file:io.cortical.rest.model.TestDataMother.java

/**
 * Create dummy  {@link Fingerprint}./*from w  w  w . j  a  v a 2 s .  com*/
 * 
 * @return dummy fingerprint.
 */
public static Fingerprint createFingerprint() {
    Random random = new Random();
    Set<Integer> positionSet = new HashSet<>();
    while (positionSet.size() <= FINGERPRINT_LENGTH) {
        positionSet.add(random.nextInt(MAX_POSITION));
    }

    Integer[] positionsInteger = new Integer[FINGERPRINT_LENGTH];
    positionsInteger = positionSet.toArray(positionsInteger);
    sort(positionsInteger);
    return new Fingerprint(ArrayUtils.toPrimitive(positionsInteger));
}

From source file:com.mirth.connect.util.MirthSSLUtil.java

public static String[] getEnabledHttpsCipherSuites(String[] requestedCipherSuites) {
    logger.debug("Requested SSL cipher suites: " + Arrays.toString(requestedCipherSuites));
    SSLContext sslContext = SSLContexts.createDefault();
    String[] supportedCipherSuites = sslContext.getSupportedSSLParameters().getCipherSuites();
    Set<String> enabledCipherSuites = new LinkedHashSet<String>();

    for (String cipherSuite : requestedCipherSuites) {
        if (ArrayUtils.contains(supportedCipherSuites, cipherSuite)) {
            enabledCipherSuites.add(cipherSuite);
        }/*from   www. j  a  v a 2 s.  com*/
    }

    logger.debug("Enabled SSL cipher suites: " + String.valueOf(enabledCipherSuites));
    return enabledCipherSuites.toArray(new String[enabledCipherSuites.size()]);
}

From source file:com.espertech.esper.event.vaevent.PropertyUtility.java

/**
 * Remove from values all removeValues and build a unique sorted result array.
 * @param values to consider//from   w ww.  j  a  v  a 2s .  co m
 * @param removeValues values to remove from values
 * @return sorted unique
 */
protected static String[] uniqueExclusiveSort(String[] values, String[] removeValues) {
    Set<String> unique = new HashSet<String>();
    unique.addAll(Arrays.asList(values));
    for (String removeValue : removeValues) {
        unique.remove(removeValue);
    }
    String[] uniqueArr = unique.toArray(new String[unique.size()]);
    Arrays.sort(uniqueArr);
    return uniqueArr;
}

From source file:net.audumla.climate.ClimateDataFactory.java

/**
 * Replaces the climate observation with a readonly version.
 *
 * @param cd the existing climate data bean
 * @return the climate data//from   w w w. j av  a2  s .  co m
 */
public static ClimateObservation convertToReadOnlyClimateObservation(ClimateObservation cd) {
    if (cd == null) {
        return null;
    }
    Set<Class<?>> interfaces = new LinkedHashSet<Class<?>>();
    interfaces.addAll(ClassUtils.getAllInterfaces(cd.getClass()));
    interfaces.remove(WritableClimateObservation.class);
    return BeanUtils.convertBean(cd, interfaces.toArray(new Class<?>[interfaces.size()]));
}

From source file:io.cloudslang.maven.compiler.CloudSlangMavenCompiler.java

protected static String[] getSourceFiles(CompilerConfiguration config) {
    Set<String> sources = new HashSet<>();

    for (String sourceLocation : config.getSourceLocations()) {
        sources.addAll(getSourceFilesForSourceRoot(config, sourceLocation));
    }/*  w  w w . java2  s  . c o m*/

    return sources.toArray(new String[sources.size()]);
}

From source file:grails.plugin.searchable.internal.compass.mapping.CompassMappingUtils.java

/**
 * Get the mapping aliases for the given user-defined domain classes any
 * @param compass Compass instance//www .  j a va2s  . co m
 * @param clazzes the user-defined domain classes
 * @return the Compass aliases for the hierarchy
 */
public static String[] getMappingAliases(Compass compass, Collection clazzes) {
    Set aliases = new HashSet();
    for (Iterator iter = clazzes.iterator(); iter.hasNext();) {
        Class clazz = (Class) iter.next();
        aliases.add(getMappingAlias(compass, clazz));
    }
    return (String[]) aliases.toArray(new String[aliases.size()]);
}

From source file:com.shenit.commons.utils.DataUtils.java

/**
 * /*w w w. jav a2s.  com*/
 * 
 * @param vals
 * @return
 */
public static <T> T[] unique(@SuppressWarnings("unchecked") T... vals) {
    if (ValidationUtils.isEmpty(vals))
        return vals;
    Set<T> set = CollectionUtils.loadSortedSet(vals);
    return set.toArray(vals);
}

From source file:info.novatec.testit.livingdoc.util.ClassUtils.java

public static ClassLoader toClassLoaderWithDefaultParent(Collection<String> classPaths)
        throws MalformedURLException {
    Set<URL> dependencies = new HashSet<URL>();
    for (String classPath : classPaths) {
        File dependency = new File(classPath);
        dependencies.add(dependency.toURI().toURL());
    }//from ww w .ja  v  a  2  s  .c o  m
    ClassLoader classLoader = URLClassLoader.newInstance(dependencies.toArray(new URL[dependencies.size()]));
    return classLoader;
}

From source file:info.novatec.testit.livingdoc.util.ClassUtils.java

public static ClassLoader toClassLoader(Collection<String> classPaths, ClassLoader parent)
        throws MalformedURLException {
    Set<URL> dependencies = new HashSet<URL>();
    for (String classPath : classPaths) {
        File dependency = new File(classPath);
        dependencies.add(dependency.toURI().toURL());
    }//  ww  w . j  ava  2  s  .co  m
    ClassLoader classLoader = URLClassLoader.newInstance(dependencies.toArray(new URL[dependencies.size()]),
            parent);
    return classLoader;
}