Рефакторинг
This commit is contained in:
@@ -10,7 +10,7 @@ import ru.serega6531.packmate.utils.Bytes;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
|
||||
public class PatternMatcher {
|
||||
class PatternMatcher {
|
||||
|
||||
private static final Map<String, java.util.regex.Pattern> compiledPatterns = new HashMap<>();
|
||||
|
||||
@@ -65,7 +65,7 @@ public class PatternMatcher {
|
||||
|
||||
startSearch = end + 1;
|
||||
}
|
||||
} else { // SUBBYTES
|
||||
} else if (pattern.getSearchType() == PatternSearchType.SUBBYTES) {
|
||||
int startSearch = 0;
|
||||
final byte[] value = Hex.decode(pattern.getValue());
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ public class ServicesService {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
public Optional<CtfService> findByPort(int port) {
|
||||
private Optional<CtfService> findByPort(int port) {
|
||||
return Optional.ofNullable(services.get(port));
|
||||
}
|
||||
|
||||
|
||||
@@ -145,7 +145,7 @@ public class StreamService {
|
||||
return foundPatterns;
|
||||
}
|
||||
|
||||
public Stream save(Stream stream) {
|
||||
private Stream save(Stream stream) {
|
||||
Stream saved;
|
||||
if (stream.getId() == null) {
|
||||
saved = repository.save(stream);
|
||||
@@ -167,6 +167,7 @@ public class StreamService {
|
||||
repository.setFavorite(id, favorite);
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
public List<Stream> findAll(Pagination pagination, Optional<Integer> service, boolean onlyFavorites) {
|
||||
PageRequest page = PageRequest.of(0, pagination.getPageSize(), pagination.getDirection(), "id");
|
||||
|
||||
|
||||
@@ -14,12 +14,13 @@ import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class StreamSubscriptionService {
|
||||
|
||||
private List<WebSocketSession> subscribers = Collections.synchronizedList(new ArrayList<>());
|
||||
private final List<WebSocketSession> subscribers = Collections.synchronizedList(new ArrayList<>());
|
||||
|
||||
private final ObjectMapper mapper;
|
||||
|
||||
@@ -30,12 +31,12 @@ public class StreamSubscriptionService {
|
||||
|
||||
public void addSubscriber(WebSocketSession session) {
|
||||
subscribers.add(session);
|
||||
log.info("Подписан пользователь {}", session.getRemoteAddress().getHostName());
|
||||
log.info("Подписан пользователь {}", Objects.requireNonNull(session.getRemoteAddress()).getHostName());
|
||||
}
|
||||
|
||||
public void removeSubscriber(WebSocketSession session) {
|
||||
subscribers.remove(session);
|
||||
log.info("Отписан пользователь {}", session.getRemoteAddress().getHostName());
|
||||
log.info("Отписан пользователь {}", Objects.requireNonNull(session.getRemoteAddress()).getHostName());
|
||||
}
|
||||
|
||||
public void broadcast(SubscriptionMessage message) {
|
||||
|
||||
Reference in New Issue
Block a user