@Test public void testGetFirstDataFormEmpty() throws Exception { final Set<DataForm> dataForms = new HashSet<>(); final DataForm result = IQDiscoInfoHandler.getFirstDataForm(dataForms); Assert.assertNull(result); }
public static DataForm getFirstDataForm(Set<DataForm> dataForms){ if(dataForms == null || dataForms.isEmpty()){ return null; } if (dataForms.size() > 1) { Log.warn("Set Data List contains "+dataForms.size()+" DataForms."+ "Only the first one of the DataForms will be returned."); } return dataForms.stream().filter(Objects::nonNull).findAny().orElse(null); }
IQDiscoInfoHandler extends IQHandler implements ClusterEventListener { public static DataForm getFirstDataForm(Set<DataForm> dataForms){ if(dataForms == null || dataForms.isEmpty()){ return null; } if (dataForms.size() > 1) { Log.warn("Set Data List contains "+dataForms.size()+" DataForms."+ "Only the first one of the DataForms will be returned."); } return dataForms.stream().filter(Objects::nonNull).findAny().orElse(null); } }
IQDiscoInfoHandler extends IQHandler implements ClusterEventListener { public static DataForm getFirstDataForm(Set<DataForm> dataForms){ if(dataForms == null || dataForms.isEmpty()){ return null; } if (dataForms.size() > 1) { Log.warn("Set Data List contains "+dataForms.size()+" DataForms."+ "Only the first one of the DataForms will be returned."); } return dataForms.stream().filter(Objects::nonNull).findAny().orElse(null); } IQDiscoInfoHandler(); }
IQDiscoInfoHandler extends IQHandler implements ClusterEventListener { public static DataForm getFirstDataForm(Set<DataForm> dataForms){ if(dataForms == null || dataForms.isEmpty()){ return null; } if (dataForms.size() > 1) { Log.warn("Set Data List contains "+dataForms.size()+" DataForms."+ "Only the first one of the DataForms will be returned."); } return dataForms.stream().filter(Objects::nonNull).findAny().orElse(null); } IQDiscoInfoHandler(); @Override IQHandlerInfo getInfo(); @Override IQ handleIQ(IQ packet); void setServerNodeInfoProvider(String node, DiscoInfoProvider provider); void removeServerNodeInfoProvider(String node); void addServerFeaturesProvider(ServerFeaturesProvider provider); void addServerIdentitiesProvider(ServerIdentitiesProvider provider); void removeServerIdentitiesProvider(ServerIdentitiesProvider provider); void addUserIdentitiesProvider(UserIdentitiesProvider provider); void removeUserIdentitiesProvider(UserIdentitiesProvider provider); void addUserFeaturesProvider(UserFeaturesProvider provider); void removeUserFeaturesProvider(UserFeaturesProvider provider); void addServerFeature(String namespace); void removeServerFeature(String namespace); @Override void initialize(XMPPServer server); @Override void joinedCluster(); @Override void joinedCluster(byte[] nodeID); @Override void leftCluster(); @Override void leftCluster(byte[] nodeID); @Override void markedAsSeniorClusterMember(); static DataForm getFirstDataForm(Set<DataForm> dataForms); static void setSoftwareVersionDataFormFromDiscoInfo(Element query ,LocalSession session); }
IQDiscoInfoHandler extends IQHandler implements ClusterEventListener { public static DataForm getFirstDataForm(Set<DataForm> dataForms){ if(dataForms == null || dataForms.isEmpty()){ return null; } if (dataForms.size() > 1) { Log.warn("Set Data List contains "+dataForms.size()+" DataForms."+ "Only the first one of the DataForms will be returned."); } return dataForms.stream().filter(Objects::nonNull).findAny().orElse(null); } IQDiscoInfoHandler(); @Override IQHandlerInfo getInfo(); @Override IQ handleIQ(IQ packet); void setServerNodeInfoProvider(String node, DiscoInfoProvider provider); void removeServerNodeInfoProvider(String node); void addServerFeaturesProvider(ServerFeaturesProvider provider); void addServerIdentitiesProvider(ServerIdentitiesProvider provider); void removeServerIdentitiesProvider(ServerIdentitiesProvider provider); void addUserIdentitiesProvider(UserIdentitiesProvider provider); void removeUserIdentitiesProvider(UserIdentitiesProvider provider); void addUserFeaturesProvider(UserFeaturesProvider provider); void removeUserFeaturesProvider(UserFeaturesProvider provider); void addServerFeature(String namespace); void removeServerFeature(String namespace); @Override void initialize(XMPPServer server); @Override void joinedCluster(); @Override void joinedCluster(byte[] nodeID); @Override void leftCluster(); @Override void leftCluster(byte[] nodeID); @Override void markedAsSeniorClusterMember(); static DataForm getFirstDataForm(Set<DataForm> dataForms); static void setSoftwareVersionDataFormFromDiscoInfo(Element query ,LocalSession session); static final String NAMESPACE_DISCO_INFO; static final SystemProperty<Boolean> ENABLED; }