Mise à jour de GitLab prévue ce samedi 8 mai 2021 à partir de 9h00 CET | GitLab upgrade planned this Saturday May 4th of 2021 from 9:00 AM CET

Commit 38e59b91 authored by Benoit Lavenier's avatar Benoit Lavenier

minor changes. Allow to used String endpoint api, instead of a fixed enumeration

parent 26665a35
Pipeline #9521 passed with stage
in 15 seconds
......@@ -71,5 +71,5 @@ public interface PeerDao extends EntityDao<String, Peer> {
void updatePeersAsDown(String currencyId, long minUpTimeInMs, Collection<String> endpointApis);
boolean hasPeersUpWithApi(String currencyId, Set<EndpointApi> endpointApis);
boolean hasPeersUpWithApi(String currencyId, Set<String> endpointApis);
}
......@@ -22,14 +22,12 @@ package org.duniter.core.client.dao.mem;
* #L%
*/
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import org.duniter.core.client.dao.PeerDao;
import org.duniter.core.client.model.bma.EndpointApi;
import org.duniter.core.client.model.bma.NetworkPeers;
import org.duniter.core.client.model.bma.NetworkWs2pHeads;
import org.duniter.core.client.model.local.Peer;
import org.duniter.core.client.model.local.Peers;
import org.duniter.core.util.Preconditions;
import java.util.*;
import java.util.stream.Collectors;
......@@ -180,11 +178,11 @@ public class MemoryPeerDaoImpl implements PeerDao {
}
@Override
public boolean hasPeersUpWithApi(String currencyId, Set<EndpointApi> api) {
public boolean hasPeersUpWithApi(String currencyId, Set<String> api) {
return getPeersByCurrencyId(currencyId)
.stream()
.anyMatch(p ->
api.contains(EndpointApi.valueOf(p.getApi())) &&
api.contains(p.getApi()) &&
p.getStats() != null &&
Peer.PeerStatus.UP.equals(p.getStats().getStatus())
);
......
......@@ -22,8 +22,8 @@ package org.duniter.core.client.model.bma;
* #L%
*/
import org.duniter.core.util.StringUtils;
import org.duniter.core.util.http.InetAddressUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.conn.util.InetAddressUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......
......@@ -25,10 +25,10 @@ package org.duniter.core.client.model.local;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.google.common.base.Joiner;
import com.google.common.base.Preconditions;
import org.apache.commons.lang3.StringUtils;
import org.duniter.core.client.model.bma.EndpointApi;
import org.duniter.core.client.model.bma.NetworkPeering;
import org.duniter.core.util.Preconditions;
import org.duniter.core.util.StringUtils;
import org.duniter.core.util.http.InetAddressUtils;
import java.io.Serializable;
......
package org.duniter.core.util;
/*
* #%L
* UCoin Java :: Core Shared
* %%
* Copyright (C) 2014 - 2016 EIS
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-3.0.html>.
* #L%
*/
import com.google.common.collect.Lists;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
/**
* Created by eis on 23/12/14.
*/
public class ArrayUtils {
public static boolean isNotEmpty(Object[] coll) {
return coll != null && coll.length > 0;
}
public static boolean isEmpty(Object[] coll) {
return coll == null || coll.length == 0;
}
public static String join(final Object[] array) {
return join(array, ", ");
}
public static String join(final Object[] array, final String separator) {
if (array == null || array.length == 0) {
return null;
}
StringBuilder sb = new StringBuilder(array.length * 7);
sb.append(array[0]);
for (int i = 1; i < array.length; i++) {
sb.append(separator);
sb.append(array[i]);
}
return sb.toString();
}
public static int size(final Object[] array) {
return array == null ? 0 : array.length;
}
}
......@@ -42,27 +42,18 @@ public class CollectionUtils {
}
public static boolean isNotEmpty(Object[] coll) {
return coll != null && coll.length > 0;
return ArrayUtils.isNotEmpty(coll);
}
public static boolean isEmpty(Object[] coll) {
return coll == null || coll.length == 0;
return ArrayUtils.isEmpty(coll);
}
public static String join(final Object[] array) {
return join(array, ", ");
return ArrayUtils.join(array);
}
public static String join(final Object[] array, final String separator) {
if (array == null || array.length == 0) {
return null;
}
StringBuilder sb = new StringBuilder(array.length * 7);
sb.append(array[0]);
for (int i = 1; i < array.length; i++) {
sb.append(separator);
sb.append(array[i]);
}
return sb.toString();
return ArrayUtils.join(array, separator);
}
public static String join(final Collection<?> collection) {
......@@ -88,7 +79,7 @@ public class CollectionUtils {
}
public static int size(final Object[] array) {
return array == null ? 0 : array.length;
return ArrayUtils.size(array);
}
public static <E> E extractSingleton(Collection<E> collection) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment