List of usage examples for java.util Set toArray
<T> T[] toArray(T[] a);
From source file:org.apache.calcite.adapter.elasticsearch.ElasticsearchSchemaFactory.java
/** * Builds elastic rest client from user configuration * @param coordinates list of {@code hostname/port} to connect to * @return newly initialized low-level rest http client for ES *//*from ww w . ja va 2 s.com*/ private static RestClient connect(Map<String, Integer> coordinates) { Objects.requireNonNull(coordinates, "coordinates"); Preconditions.checkArgument(!coordinates.isEmpty(), "no ES coordinates specified"); final Set<HttpHost> set = new LinkedHashSet<>(); for (Map.Entry<String, Integer> entry : coordinates.entrySet()) { set.add(new HttpHost(entry.getKey(), entry.getValue())); } return RestClient.builder(set.toArray(new HttpHost[0])).build(); }
From source file:co.turnus.analysis.util.AnalysisUtil.java
public static int[] linspacei(int min, int max, int points) { Set<Integer> values = new LinkedHashSet<Integer>(); values.add(min);//w ww. j a v a2s . c o m for (double d : linspaced(min, max, points)) { values.add((int) Math.floor(d)); } values.add(max); return ArrayUtils.toPrimitive(values.toArray(new Integer[0])); }
From source file:cop.raml.utils.Utils.java
/** * Converts enum constants as set {@code anEnum} to enum string without any duplication. * * @param anEnum set of enum constants/* w ww . jav a 2s. com*/ * @return {@code null} or not empty enum string (e.g. [one,two]) */ public static String toEnumStr(Set<String> anEnum) { return CollectionUtils.isNotEmpty(anEnum) ? toEnumStr(anEnum.toArray(new String[anEnum.size()])) : null; }
From source file:spring.osgi.utils.OsgiResourceUtils.java
public static Resource[] convertURLEnumerationToResourceArray(Enumeration enm) { Set<Resource> resources = new LinkedHashSet<>(4); while (enm != null && enm.hasMoreElements()) { resources.add(new UrlResource((URL) enm.nextElement())); }/*from www. j a v a 2s. c om*/ return resources.toArray(new Resource[resources.size()]); }
From source file:com.marklogic.entityservices.tests.TestExtractionTemplates.java
@AfterClass public static void removeTemplates() { Set<String> toDelete = new HashSet<String>(); extractionTemplates.keySet().forEach(x -> toDelete.add(x.replaceAll("json", "tdex"))); docMgr.delete(toDelete.toArray(new String[] {})); }
From source file:com.hs.mail.deliver.Deliver.java
private static String[] getRecipients(MessageHeader header) { Set<String> rcpts = new HashSet<String>(); getRecipients(header.getTo(), rcpts); getRecipients(header.getCc(), rcpts); getRecipients(header.getBcc(), rcpts); return rcpts.toArray(new String[0]); }
From source file:net.sf.keystore_explorer.gui.CreateApplicationGui.java
private static void setDefaultSize(int size) { Set<Object> keySet = UIManager.getLookAndFeelDefaults().keySet(); Object[] keys = keySet.toArray(new Object[keySet.size()]); for (Object key : keys) { if (key != null && key.toString().toLowerCase().contains("font")) { Font font = UIManager.getDefaults().getFont(key); if (font != null) { font = font.deriveFont((float) size); UIManager.put(key, font); }//from w w w . jav a2 s .co m } } }
From source file:co.turnus.analysis.util.AnalysisUtil.java
public static double[] linspaced(double min, double max, int points) { Set<Double> values = new LinkedHashSet<Double>(); double current = min; double delta = (max - min) / ((double) points - 1); do {/*w ww.j a v a2 s . c o m*/ values.add(current); current += delta; } while (current < (max + delta / 2)); return ArrayUtils.toPrimitive(values.toArray(new Double[0])); }
From source file:net.sf.beanlib.CollectionPropertyName.java
/** Convenient factory method. */ public static <T> CollectionPropertyName<T>[] createCollectionPropertyNames(Class<T> declaringClass, String[] collectionProperties) { Set<CollectionPropertyName<T>> set = new HashSet<CollectionPropertyName<T>>(); for (String s : collectionProperties) set.add(new CollectionPropertyName<T>(declaringClass, s)); @SuppressWarnings("unchecked") CollectionPropertyName<T>[] ret = (CollectionPropertyName<T>[]) set.toArray(EMPTY_ARRAY); return ret;//w w w. java 2 s . c om }
From source file:csv.parser.CSVParser.java
private static String[] getEduLvl(String[] val) { for (int i = 0; i < val.length; i++) { if (val[i].equals("Under Graduate") || val[i].equals("Post Graduate")) { val[i] = "ug_pg"; } else if (val[i].equals("I") || val[i].equals("II") || val[i].equals("III") || val[i].equals("IV")) { val[i] = "lowerPrimary"; } else if (val[i].equals("V") || val[i].equals("VI") || val[i].equals("VII") || val[i].equals("VIII")) { val[i] = "upperPrimary"; } else if (val[i].equals("IX") || val[i].equals("X")) { val[i] = "middleSchool"; } else if (val[i].equals("XI") || val[i].equals("XII")) { val[i] = "highSchool"; }//from w w w . jav a 2s.c om } int end = val.length; Set<String> set = new HashSet<String>(); for (int i = 0; i < end; i++) { set.add(val[i]); } val = set.toArray(new String[set.size()]); return val; }