List of usage examples for java.util TreeSet TreeSet
public TreeSet(SortedSet<E> s)
From source file:com.sonoport.freesound.response.mapping.AudioDescriptorsMapper.java
@Override public AudioDescriptors map(final JSONObject source) { final AudioDescriptors audioDescriptors = new AudioDescriptors(); final JSONObject fixedLengthDescriptors = extractFieldValue(source, "fixed-length", JSONObject.class); final JSONArray fixedLengthOneDimensionalDescriptors = extractFieldValue(fixedLengthDescriptors, "one-dimensional", JSONArray.class); audioDescriptors/*from w w w. jav a 2s . c om*/ .setFixedLengthOneDimensional(new TreeSet<>(parseArray(fixedLengthOneDimensionalDescriptors))); final JSONArray fixedLengthMultiDimensionalDescriptors = extractFieldValue(fixedLengthDescriptors, "multi-dimensional", JSONArray.class); audioDescriptors .setFixedLengthMultiDimensional(new TreeSet<>(parseArray(fixedLengthMultiDimensionalDescriptors))); final JSONArray variableLengthDescriptors = extractFieldValue(source, "variable-length", JSONArray.class); audioDescriptors.setVariableLength(new TreeSet<>(parseArray(variableLengthDescriptors))); return audioDescriptors; }
From source file:com.pc.dailymile.domain.Friends.java
public Set<User> getFriends() { if (friends == null) { return Collections.emptySet(); }//from w w w . j av a 2s .co m return new TreeSet<User>(friends); }
From source file:org.mapfish.print.config.ConfigTest.java
public void testBestScale() { Config config = new Config(); try {//from ww w . j av a2 s .c om TreeSet<Integer> scales = new TreeSet<Integer>(Arrays.asList(200000, 25000, 50000, 100000)); config.setScales(scales); assertEquals("Too small scale => pick the smallest available", 25000, config.getBestScale(1)); assertEquals("Exact match", 25000, config.getBestScale(25000.0)); assertEquals("Just too big => should still take the previous one", 25000, config.getBestScale(25000.1)); assertEquals("Normal behaviour", 200000, config.getBestScale(150000)); assertEquals("Just a litle before", 200000, config.getBestScale(199999.9)); assertEquals("When we want a scale that is too big, pick the highest available", 200000, config.getBestScale(99999999999.0)); } finally { config.close(); } }
From source file:com.thoughtworks.go.server.ui.AgentViewModel.java
public AgentViewModel(AgentInstance agentInstance, Collection<String> environments) { this.agentInstance = agentInstance; this.environments = new TreeSet<>(environments); }
From source file:byps.test.TestRemoteSetTypes.java
@Test public void testRemoteSetTypes() throws RemoteException { log.info("testRemoteSetTypes("); SetTypes obj = new SetTypes(); obj.boolean1 = new HashSet<Boolean>(Arrays.asList(true, false)); obj.byte1 = new HashSet<Byte>(Arrays.asList((byte) 1, (byte) 2, (byte) 3)); obj.char1 = new TreeSet<Character>(Arrays.asList('a', 'b')); obj.double1 = new HashSet<Double>(Arrays.asList(0.0, 0.1, 0.2)); obj.float1 = new HashSet<Float>(Arrays.asList(1f, 2f, 3f, 4f)); obj.int1 = new HashSet<Integer>(Arrays.asList(1, 2, 3, 4, 5)); obj.long1 = new HashSet<Long>(Arrays.asList(1L, 2L, 3L, 4L, 5L, 6L)); obj.primitiveTypes1 = new HashSet<PrimitiveTypes>( Arrays.asList(new PrimitiveTypes[] { TestUtils.createObjectPrimitiveTypes() })); obj.short1 = new HashSet<Short>(Arrays.asList((short) 1)); obj.string1 = new HashSet<String>(Arrays.asList("a", "b", "c")); obj.obj1 = new HashSet<Object>( Arrays.asList(new PrimitiveTypes[] { TestUtils.createObjectPrimitiveTypes() })); obj.date1 = new HashSet<Date>(Arrays.asList(new Date(0))); remote.setBoolean1(obj.boolean1); TestUtils.assertEquals(log, "boolean1", obj.boolean1, remote.getBoolean1()); remote.setByte1(obj.byte1); TestUtils.assertEquals(log, "byte1", obj.byte1, remote.getByte1()); remote.setChar1(obj.char1); TestUtils.assertEquals(log, "char1", obj.char1, remote.getChar1()); remote.setDouble1(obj.double1); TestUtils.assertEquals(log, "double1", obj.double1, remote.getDouble1()); remote.setFloat1(obj.float1); TestUtils.assertEquals(log, "float1", obj.float1, remote.getFloat1()); remote.setInt1(obj.int1); TestUtils.assertEquals(log, "int1", obj.int1, remote.getInt1()); remote.setLong1(obj.long1); TestUtils.assertEquals(log, "long1", obj.long1, remote.getLong1()); remote.setPrimitiveTypes1(obj.primitiveTypes1); TestUtils.assertEquals(log, "primitiveTypes1", obj.primitiveTypes1, remote.getPrimitiveTypes1()); remote.setShort1(obj.short1); TestUtils.assertEquals(log, "short1", obj.short1, remote.getShort1()); remote.setString1(obj.string1);/* www. j a va 2s . co m*/ TestUtils.assertEquals(log, "string1", obj.string1, remote.getString1()); remote.setObj1(obj.obj1); TestUtils.assertEquals(log, "obj1", obj.obj1, remote.getObj1()); remote.setDate1(obj.date1); TestUtils.assertEquals(log, "date1", obj.date1, remote.getDate1()); log.info(")testRemoteSetTypes"); }
From source file:de.tudarmstadt.ukp.dkpro.argumentation.sequence.report.ConfusionMatrixTools.java
public static String prettyPrintConfusionMatrixResults(ConfusionMatrix cm) { cm.printNiceResults();/*from w w w . j a va2 s .co m*/ String f = "%.3f"; List<String> header = new ArrayList<>(); List<String> row = new ArrayList<>(); header.add("Macro F1"); header.add("Accuracy"); header.add("Acc CI@95"); row.add(String.format(Locale.ENGLISH, f, cm.getMacroFMeasure())); row.add(String.format(Locale.ENGLISH, f, cm.getAccuracy())); row.add(String.format(Locale.ENGLISH, f, cm.getConfidence95Accuracy())); Map<String, Double> precisionForLabels = cm.getPrecisionForLabels(); Map<String, Double> recallForLabels = cm.getRecallForLabels(); Map<String, Double> fMForLabels = cm.getFMeasureForLabels(); SortedSet<String> labels = new TreeSet<>(precisionForLabels.keySet()); for (String label : labels) { header.add(label + " P"); row.add(String.format(Locale.ENGLISH, f, precisionForLabels.get(label))); header.add(label + " R"); row.add(String.format(Locale.ENGLISH, f, recallForLabels.get(label))); header.add(label + " F1"); row.add(String.format(Locale.ENGLISH, f, fMForLabels.get(label))); } return StringUtils.join(header, GLUE) + "\n" + StringUtils.join(row, GLUE); }
From source file:com.github.fritaly.dualcommander.SortedListModel.java
public SortedListModel(Comparator<E> comparator) { Validate.notNull(comparator, "The given comparator is null"); this.model = new TreeSet<E>(comparator); }
From source file:it.geosolutions.geoserver.jms.JMSManager.java
/** * Method to make lookup using the type of the passed eventType. * //from w w w.j a v a 2 s . c om * @param <S> * @param <O> * @param eventType * @return the handler * @throws IllegalArgumentException */ public <S extends Serializable, O> JMSEventHandler<S, O> getHandler(final O eventType) throws IllegalArgumentException { final Set<?> beanSet = beans.entrySet(); // declare a tree set to define the handler priority final Set<JMSEventHandlerSPI<S, O>> candidates = new TreeSet<JMSEventHandlerSPI<S, O>>( new Comparator<JMSEventHandlerSPI<S, O>>() { @Override public int compare(JMSEventHandlerSPI<S, O> o1, JMSEventHandlerSPI<S, O> o2) { if (o1.getPriority() < o2.getPriority()) return -1; else if (o1.getPriority() == o2.getPriority()) { return 0; // } else if (o1.getPriority()>o2.getPriority()){ } else { return 1; } } }); // for each handler check if it 'canHandle' the incoming object if so // add it to the tree for (final Iterator<?> it = beanSet.iterator(); it.hasNext();) { final Map.Entry<String, ?> entry = (Entry<String, ?>) it.next(); final JMSEventHandlerSPI<S, O> spi = (JMSEventHandlerSPI) entry.getValue(); if (spi != null) { if (spi.canHandle(eventType)) { if (LOGGER.isLoggable(Level.INFO)) LOGGER.info("Creating an instance of: " + spi.getClass()); candidates.add(spi); } } } // TODO return the entire tree leaving choice to the caller (useful to // build a failover list) // return the first available handler final Iterator<JMSEventHandlerSPI<S, O>> it = candidates.iterator(); while (it.hasNext()) { try { final JMSEventHandler<S, O> handler = it.next().createHandler(); if (handler != null) return handler; } catch (Exception e) { if (LOGGER.isLoggable(Level.WARNING)) LOGGER.log(Level.WARNING, e.getLocalizedMessage(), e); } } final String message = "Unable to find the needed Handler SPI for event of type: " + eventType.getClass().getCanonicalName(); if (LOGGER.isLoggable(Level.WARNING)) LOGGER.warning(message); throw new IllegalArgumentException(message); }
From source file:com.vrem.wifianalyzer.wifi.band.WiFiChannelCountryGHZ2.java
SortedSet<Integer> findChannels(@NonNull String countryCode) { SortedSet<Integer> results = new TreeSet<>(world); String code = StringUtils.capitalize(countryCode); if (countries.contains(code)) { results = new TreeSet<>(channels); }/* w w w. j ava2 s. c o m*/ return results; }
From source file:com.mycsense.carbondb.domain.SingleElement.java
public SingleElement(TreeSet<Keyword> keywords, Unit unit) { this.keywords = new TreeSet<>(keywords); this.unit = unit; groups = new HashSet<>(); }