List of usage examples for org.apache.commons.collections4 CollectionUtils isEmpty
public static boolean isEmpty(final Collection<?> coll)
From source file:io.cloudslang.lang.tools.build.ArgumentProcessorUtils.java
/** * @param stringList the list of strings * @return A string joining the test suite names using io.cloudslang.lang.tools.build.SlangBuildMain#LIST_JOINER *//*from w ww .ja v a 2 s. c o m*/ public static String getListForPrint(final List<String> stringList) { return CollectionUtils.isEmpty(stringList) ? EMPTY : join(stringList, LIST_JOINER); }
From source file:com.mirth.connect.connectors.tcp.TcpListener.java
@Override public void setProperties(ConnectorProperties properties) { TcpReceiverProperties props = (TcpReceiverProperties) properties; TransmissionModeProperties modeProps = props.getTransmissionModeProperties(); String name = "Basic TCP"; if (modeProps != null && LoadedExtensions.getInstance().getTransmissionModePlugins() .containsKey(modeProps.getPluginPointName())) { name = modeProps.getPluginPointName(); }/*from w ww . j a v a2 s.c om*/ modeLock = true; transmissionModeComboBox.setSelectedItem(name); transmissionModeComboBoxActionPerformed(); modeLock = false; selectedMode = name; if (transmissionModeProvider != null) { transmissionModeProvider.setProperties(modeProps); } if (props.isServerMode()) { modeServerRadio.setSelected(true); modeServerRadioActionPerformed(); } else { modeClientRadio.setSelected(true); modeClientRadioActionPerformed(); } remoteAddressField.setText(props.getRemoteAddress()); remotePortField.setText(props.getRemotePort()); if (props.isOverrideLocalBinding()) { overrideLocalBindingYesRadio.setSelected(true); } else { overrideLocalBindingNoRadio.setSelected(true); } reconnectIntervalField.setText(props.getReconnectInterval()); receiveTimeoutField.setText(props.getReceiveTimeout()); bufferSizeField.setText(props.getBufferSize()); maxConnectionsField.setText(props.getMaxConnections()); if (props.isKeepConnectionOpen()) { keepConnectionOpenYesRadio.setSelected(true); } else { keepConnectionOpenNoRadio.setSelected(true); } if (props.isDataTypeBinary()) { dataTypeBinaryRadio.setSelected(true); dataTypeBinaryRadioActionPerformed(); } else { dataTypeTextRadio.setSelected(true); dataTypeASCIIRadioActionPerformed(); } parent.setPreviousSelectedEncodingForConnector(charsetEncodingComboBox, props.getCharsetEncoding()); if (responseConnectorPropertiesPanel != null) { Set<ConnectorPluginProperties> connectorPluginProperties = props.getResponseConnectorPluginProperties(); if (CollectionUtils.isEmpty(connectorPluginProperties)) { connectorPluginProperties = new HashSet<ConnectorPluginProperties>(); connectorPluginProperties.add(responseConnectorPropertiesPanel.getDefaults()); } ConnectorPluginProperties pluginProperties = connectorPluginProperties.iterator().next(); if (!(pluginProperties instanceof InvalidConnectorPluginProperties)) { responseConnectorPropertiesPanel.setProperties(properties, pluginProperties, Mode.DESTINATION, props.getName()); } } switch (props.getRespondOnNewConnection()) { case TcpReceiverProperties.NEW_CONNECTION: respondOnNewConnectionYesRadio.setSelected(true); respondOnNewConnectionYesRadioActionPerformed(); break; case TcpReceiverProperties.SAME_CONNECTION: respondOnNewConnectionNoRadio.setSelected(true); respondOnNewConnectionNoRadioActionPerformed(); break; case TcpReceiverProperties.NEW_CONNECTION_ON_RECOVERY: respondOnNewConnectionRecoveryRadio.setSelected(true); respondOnNewConnectionRecoveryRadioActionPerformed(); break; } responseAddressField.setText(props.getResponseAddress()); responsePortField.setText(props.getResponsePort()); }
From source file:fr.landel.utils.commons.CastUtilsTest.java
/** * Check cast hash set/*from ww w . j a va 2 s . c o m*/ */ @Test public void testGetSet() { Set<Object> set = new HashSet<>(); set.add("test2"); set.add(null); set.add("test1"); assertTrue(CollectionUtils.isEmpty(CastUtils.getHashSet(null, null))); assertTrue(CollectionUtils.isEmpty(CastUtils.getHashSet(null, String.class))); assertTrue(CollectionUtils.isEmpty(CastUtils.getTreeSet(null, String.class))); assertTrue(CollectionUtils.isEmpty(CastUtils.getTreeSet(null, String.class, COMPARATOR))); assertTrue(CollectionUtils.isEmpty(CastUtils.getHashSet(2, String.class))); Set<String> result = CastUtils.getHashSet(set, String.class); assertEquals(2, result.size()); assertTrue(result.contains("test1")); assertTrue(result.contains("test2")); result = CastUtils.getTreeSet(set, String.class); assertEquals(2, result.size()); Iterator<String> it = result.iterator(); assertEquals("test1", it.next()); assertEquals("test2", it.next()); result = CastUtils.getTreeSet(set, String.class, COMPARATOR); assertEquals(2, result.size()); it = result.iterator(); assertEquals("test2", it.next()); assertEquals("test1", it.next()); }
From source file:co.rsk.net.discovery.PeerExplorerTest.java
@Test public void handlePongMessage() throws Exception { List<String> nodes = new ArrayList<>(); nodes.add(HOST_1 + ":" + PORT_1); nodes.add(HOST_3 + ":" + PORT_3); ECKey key1 = ECKey.fromPrivate(Hex.decode(KEY_1)).decompress(); ECKey key2 = ECKey.fromPrivate(Hex.decode(KEY_2)).decompress(); Node node = new Node(key2.getNodeId(), HOST_2, PORT_2); NodeDistanceTable distanceTable = new NodeDistanceTable(KademliaOptions.BINS, KademliaOptions.BUCKET_SIZE, node);/*ww w . j ava2 s .c om*/ PeerExplorer peerExplorer = new PeerExplorer(nodes, node, distanceTable, key2, TIMEOUT, REFRESH); Channel internalChannel = Mockito.mock(Channel.class); UDPTestChannel channel = new UDPTestChannel(internalChannel, peerExplorer); ChannelHandlerContext ctx = Mockito.mock(ChannelHandlerContext.class); peerExplorer.setUDPChannel(channel); Assert.assertTrue(CollectionUtils.isEmpty(peerExplorer.getNodes())); //A incoming pong for a Ping we did not sent. String check = UUID.randomUUID().toString(); PongPeerMessage incomingPongMessage = PongPeerMessage.create(HOST_1, PORT_1, check, key1); DiscoveryEvent incomingPongEvent = new DiscoveryEvent(incomingPongMessage, new InetSocketAddress(HOST_1, PORT_1)); channel.clearEvents(); channel.channelRead0(ctx, incomingPongEvent); List<DiscoveryEvent> sentEvents = channel.getEventsWritten(); Assert.assertEquals(0, sentEvents.size()); Assert.assertEquals(0, peerExplorer.getNodes().size()); //Now we send the ping first peerExplorer.startConversationWithNewNodes(); sentEvents = channel.getEventsWritten(); Assert.assertEquals(2, sentEvents.size()); incomingPongMessage = PongPeerMessage.create(HOST_1, PORT_1, ((PingPeerMessage) sentEvents.get(0).getMessage()).getMessageId(), key1); incomingPongEvent = new DiscoveryEvent(incomingPongMessage, new InetSocketAddress(HOST_1, PORT_1)); channel.clearEvents(); List<Node> addedNodes = peerExplorer.getNodes(); Assert.assertEquals(0, addedNodes.size()); channel.channelRead0(ctx, incomingPongEvent); Assert.assertEquals(1, peerExplorer.getNodes().size()); addedNodes = peerExplorer.getNodes(); Assert.assertEquals(1, addedNodes.size()); }
From source file:monasca.api.infrastructure.persistence.hibernate.AlarmDefinitionSqlRepoImpl.java
@Override public String exists(final String tenantId, final String name) { logger.trace(ORM_LOG_MARKER, "exists(...) entering..."); StatelessSession session = null;// w w w . j ava 2 s. c o m try { session = sessionFactory.openStatelessSession(); List<?> ids = session.createCriteria(AlarmDefinitionDb.class).add(Restrictions.eq("tenantId", tenantId)) .add(Restrictions.eq("name", name)).add(Restrictions.isNull("deletedAt")) .setProjection(Projections.property("id")).setMaxResults(1).list(); final String existingId = CollectionUtils.isEmpty(ids) ? null : (String) ids.get(0); if (null == existingId) { logger.debug(ORM_LOG_MARKER, "No AlarmDefinition matched tenantId={} and name={}", tenantId, name); } return existingId; } finally { if (session != null) { session.close(); } } }
From source file:it.gulch.linuxday.android.services.AlarmIntentService.java
private void notifyEvent(Intent intent) { long eventId = Long.parseLong(intent.getDataString()); Event event = eventManager.get(eventId); if (event == null) { return;// w w w.j a va 2 s .c om } // NotificationManager notificationManager = (NotificationManager) getSystemService(Context // .NOTIFICATION_SERVICE); // PendingIntent eventPendingIntent = // TaskStackBuilder.create(this).addNextIntent(new Intent(this, // MainActivity.class)).addNextIntent( // new Intent(this, EventDetailsActivity.class).setData(Uri.parse(String.valueOf(event // .getId())))) // .getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); PendingIntent eventPendingIntent = TaskStackBuilder.create(this) .addNextIntent(new Intent(this, MainActivity.class)) .addNextIntent(new Intent(this, EventDetailsActivity.class) .setData(Uri.parse(String.valueOf(event.getId())))) .getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); int defaultFlags = Notification.DEFAULT_SOUND; SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); if (sharedPreferences.getBoolean(SettingsFragment.KEY_PREF_NOTIFICATIONS_VIBRATE, false)) { defaultFlags |= Notification.DEFAULT_VIBRATE; } String trackName = event.getTrack().getTitle(); CharSequence bigText; String contentText; if (CollectionUtils.isEmpty(event.getPeople())) { contentText = trackName; bigText = event.getSubtitle(); } else { String personsSummary = StringUtils.join(event.getPeople(), ", "); contentText = String.format("%1$s - %2$s", trackName, personsSummary); String subTitle = event.getSubtitle(); SpannableString spannableBigText; if (TextUtils.isEmpty(subTitle)) { spannableBigText = new SpannableString(personsSummary); } else { spannableBigText = new SpannableString(String.format("%1$s\n%2$s", subTitle, personsSummary)); } // Set the persons summary in italic spannableBigText.setSpan(new StyleSpan(Typeface.ITALIC), +spannableBigText.length() - personsSummary.length(), spannableBigText.length(), +Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); bigText = spannableBigText; } String roomName = event.getTrack().getRoom().getName(); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_launcher).setWhen(event.getStartDate().getTime()) .setContentTitle(event.getTitle()).setContentText(contentText) .setStyle(new NotificationCompat.BigTextStyle().bigText(bigText).setSummaryText(trackName)) .setContentInfo(roomName).setContentIntent(eventPendingIntent).setAutoCancel(true) .setDefaults(defaultFlags).setPriority(NotificationCompat.PRIORITY_HIGH); // Blink the LED with FOSDEM color if enabled in the options if (sharedPreferences.getBoolean(SettingsFragment.KEY_PREF_NOTIFICATIONS_LED, false)) { notificationBuilder.setLights(getResources().getColor(R.color.maincolor), 1000, 5000); } /*// Android Wear extensions NotificationCompat.WearableExtender wearableExtender = new NotificationCompat.WearableExtender(); // Add an optional action button to show the room map image int roomImageResId = getResources() .getIdentifier(StringUtils.roomNameToResourceName(roomName), "drawable", getPackageName()); if(roomImageResId != 0) { // The room name is the unique Id of a RoomImageDialogActivity Intent mapIntent = new Intent(this, RoomImageDialogActivity.class).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK) .setData(Uri.parse(roomName)); mapIntent.putExtra(RoomImageDialogActivity.EXTRA_ROOM_NAME, roomName); mapIntent.putExtra(RoomImageDialogActivity.EXTRA_ROOM_IMAGE_RESOURCE_ID, roomImageResId); PendingIntent mapPendingIntent = PendingIntent.getActivity(this, 0, mapIntent, PendingIntent.FLAG_UPDATE_CURRENT); CharSequence mapTitle = getString(R.string.room_map); notificationBuilder .addAction(new NotificationCompat.Action(R.drawable.ic_action_place, mapTitle, mapPendingIntent)); // Use bigger action icon for wearable notification wearableExtender.addAction( new NotificationCompat.Action(R.drawable.ic_place_white_wear, mapTitle, mapPendingIntent)); } notificationBuilder.extend(wearableExtender);*/ NotificationManagerCompat.from(this).notify((int) eventId, notificationBuilder.build()); }
From source file:com.haulmont.cuba.core.global.QueryParserAstBased.java
protected EntityNameAndPath getEntityNameAndPathIfSecondaryReturnedInsteadOfMain() { List<PathNode> returnedPathNodes = getQueryAnalyzer().getReturnedPathNodes(); if (CollectionUtils.isEmpty(returnedPathNodes) || returnedPathNodes.size() > 1) { return null; }/*from w w w . ja v a2 s . c om*/ QueryVariableContext rootQueryVariableContext = getQueryAnalyzer().getRootQueryVariableContext(); PathNode pathNode = returnedPathNodes.get(0); if (pathNode.getChildren() == null) { JpqlEntityModel entity = rootQueryVariableContext .getEntityByVariableName(pathNode.getEntityVariableName()); if (entity != null) { if (!Objects.equals(entity.getName(), getEntityName())) { return new EntityNameAndPath(entity.getName(), pathNode.getEntityVariableName()); } //fix for scary Eclipselink which consider "select p from sec$GroupHierarchy h join h.parent p" //(even if h.parent is also sec$GroupHierarchy) //as report query and does not allow to set view IdentificationVariableNode mainEntityIdentification = getQueryAnalyzer() .getMainEntityIdentification(); if (mainEntityIdentification != null && !pathNode.getEntityVariableName().equals(mainEntityIdentification.getVariableName())) { return entity.getName() != null ? new EntityNameAndPath(entity.getName(), pathNode.getEntityVariableName()) : null; } } return null; } JpqlEntityModel entity; String entityPath; boolean collectionSelect = false; try { entity = rootQueryVariableContext.getEntityByVariableName(pathNode.getEntityVariableName()); if (entity != null) { entityPath = pathNode.asPathString(); for (int i = 0; i < pathNode.getChildCount(); i++) { String fieldName = pathNode.getChild(i).toString(); Attribute entityAttribute = entity.getAttributeByName(fieldName); if (entityAttribute != null && entityAttribute.isEntityReferenceAttribute()) { entity = model.getEntityByName(entityAttribute.getReferencedEntityName()); if (!collectionSelect) { collectionSelect = entityAttribute.isCollection(); } } else { return null; } } } else { return null; } } catch (UnknownEntityNameException e) { throw new RuntimeException(format("Unable to find entity by name %s", e.getEntityName()), e); } return entity != null && entity.getName() != null ? new EntityNameAndPath(entity.getName(), entityPath, collectionSelect) : null; }
From source file:io.ucoin.ucoinj.web.pages.home.HomePage.java
protected List<String> doSuggestions(final String input) { List<String> suggestions; if (StringUtils.isEmpty(input)) { suggestions = Collections.<String>emptyList(); } else {// w w w.j a v a 2s . c om CurrencyIndexerService service = ServiceLocator.instance().getCurrencyIndexerService(); suggestions = service.getSuggestions(input); if (CollectionUtils.isEmpty(suggestions)) { suggestions = Collections.<String>emptyList(); } } return suggestions; }
From source file:it.reply.orchestrator.service.OneDataServiceImpl.java
@Override public OneData populateProviderInfo(OneData onedataParameter) { boolean addAllProvidersinfo = false; if (CollectionUtils.isEmpty(onedataParameter.getProviders())) { addAllProvidersinfo = true;//from w w w . j a v a 2 s .c o m } else { // FIXME remove once all the logic has been implemented return onedataParameter; } UserSpaces spaces = getUserSpacesId(onedataParameter.getZone(), onedataParameter.getToken()); List<String> providersId = Lists.newArrayList(); SpaceDetails spaceDetail = null; for (String spaceId : spaces.getSpaces()) { spaceDetail = getSpaceDetailsFromId(onedataParameter.getZone(), onedataParameter.getToken(), spaceId); if (Objects.equals(onedataParameter.getSpace(), spaceDetail.getCanonicalName())) { providersId.addAll(spaceDetail.getProvidersSupports().keySet()); break; } } if (spaceDetail == null) { throw new DeploymentException(String.format("Could not found space %s in onezone %s", onedataParameter.getSpace(), onedataParameter.getZone() != null ? onedataParameter.getZone() : defaultOneZoneEndpoint)); } for (String providerId : providersId) { ProviderDetails providerDetails = getProviderDetailsFromId(onedataParameter.getZone(), onedataParameter.getToken(), spaceDetail.getSpaceId(), providerId); if (addAllProvidersinfo) { OneDataProviderInfo providerInfo = new OneDataProviderInfo(); providerInfo.id = providerId; providerInfo.endpoint = providerDetails.getRedirectionPoint(); onedataParameter.getProviders().add(providerInfo); } else { // TODO implement the logic } } return onedataParameter; }
From source file:nc.noumea.mairie.appock.entity.Demande.java
/** * @return l'avancement du traitement de la demande *///from ww w.j a v a 2 s . c om public int getAvancementTraitement() { double i = 0; for (ArticleDemande articleDemande : listeArticleDemande) { if (articleDemande.getEtatArticleDemande() != null) { i++; } } if (CollectionUtils.isEmpty(listeArticleDemande)) { return 0; } return AppockUtil.arrondiDizaine(i / listeArticleDemande.size()); }