Removed stream usage from PunishmentHolder.

This commit is contained in:
MobiusDevelopment 2023-01-08 14:52:54 +00:00
parent b4c8bb7bfc
commit 834387f340
29 changed files with 403 additions and 290 deletions

View File

@ -37,8 +37,7 @@ public class PunishmentHolder
{ {
if (!task.isExpired()) if (!task.isExpired())
{ {
final String key = String.valueOf(task.getKey()); _holder.computeIfAbsent(String.valueOf(task.getKey()), k -> new ConcurrentHashMap<>()).put(task.getType(), task);
_holder.computeIfAbsent(key, k -> new ConcurrentHashMap<>()).put(task.getType(), task);
} }
} }
@ -63,17 +62,22 @@ public class PunishmentHolder
public void stopPunishment(PunishmentType type) public void stopPunishment(PunishmentType type)
{ {
_holder.values().stream().flatMap(p -> p.values().stream()).filter(p -> p.getType() == type).forEach(t -> for (Map<PunishmentType, PunishmentTask> punishments : _holder.values())
{ {
t.stopPunishment(); for (PunishmentTask task : punishments.values())
final String key = String.valueOf(t.getKey()); {
final Map<PunishmentType, PunishmentTask> punishments = _holder.get(key); if (task.getType() == type)
punishments.remove(t.getType()); {
task.stopPunishment();
final String key = String.valueOf(task.getKey());
punishments.remove(task.getType());
if (punishments.isEmpty()) if (punishments.isEmpty())
{ {
_holder.remove(key); _holder.remove(key);
} }
}); }
}
}
} }
/** /**

View File

@ -37,8 +37,7 @@ public class PunishmentHolder
{ {
if (!task.isExpired()) if (!task.isExpired())
{ {
final String key = String.valueOf(task.getKey()); _holder.computeIfAbsent(String.valueOf(task.getKey()), k -> new ConcurrentHashMap<>()).put(task.getType(), task);
_holder.computeIfAbsent(key, k -> new ConcurrentHashMap<>()).put(task.getType(), task);
} }
} }
@ -63,17 +62,22 @@ public class PunishmentHolder
public void stopPunishment(PunishmentType type) public void stopPunishment(PunishmentType type)
{ {
_holder.values().stream().flatMap(p -> p.values().stream()).filter(p -> p.getType() == type).forEach(t -> for (Map<PunishmentType, PunishmentTask> punishments : _holder.values())
{ {
t.stopPunishment(); for (PunishmentTask task : punishments.values())
final String key = String.valueOf(t.getKey()); {
final Map<PunishmentType, PunishmentTask> punishments = _holder.get(key); if (task.getType() == type)
punishments.remove(t.getType()); {
task.stopPunishment();
final String key = String.valueOf(task.getKey());
punishments.remove(task.getType());
if (punishments.isEmpty()) if (punishments.isEmpty())
{ {
_holder.remove(key); _holder.remove(key);
} }
}); }
}
}
} }
/** /**

View File

@ -37,8 +37,7 @@ public class PunishmentHolder
{ {
if (!task.isExpired()) if (!task.isExpired())
{ {
final String key = String.valueOf(task.getKey()); _holder.computeIfAbsent(String.valueOf(task.getKey()), k -> new ConcurrentHashMap<>()).put(task.getType(), task);
_holder.computeIfAbsent(key, k -> new ConcurrentHashMap<>()).put(task.getType(), task);
} }
} }
@ -63,17 +62,22 @@ public class PunishmentHolder
public void stopPunishment(PunishmentType type) public void stopPunishment(PunishmentType type)
{ {
_holder.values().stream().flatMap(p -> p.values().stream()).filter(p -> p.getType() == type).forEach(t -> for (Map<PunishmentType, PunishmentTask> punishments : _holder.values())
{ {
t.stopPunishment(); for (PunishmentTask task : punishments.values())
final String key = String.valueOf(t.getKey()); {
final Map<PunishmentType, PunishmentTask> punishments = _holder.get(key); if (task.getType() == type)
punishments.remove(t.getType()); {
task.stopPunishment();
final String key = String.valueOf(task.getKey());
punishments.remove(task.getType());
if (punishments.isEmpty()) if (punishments.isEmpty())
{ {
_holder.remove(key); _holder.remove(key);
} }
}); }
}
}
} }
/** /**

View File

@ -37,8 +37,7 @@ public class PunishmentHolder
{ {
if (!task.isExpired()) if (!task.isExpired())
{ {
final String key = String.valueOf(task.getKey()); _holder.computeIfAbsent(String.valueOf(task.getKey()), k -> new ConcurrentHashMap<>()).put(task.getType(), task);
_holder.computeIfAbsent(key, k -> new ConcurrentHashMap<>()).put(task.getType(), task);
} }
} }
@ -63,17 +62,22 @@ public class PunishmentHolder
public void stopPunishment(PunishmentType type) public void stopPunishment(PunishmentType type)
{ {
_holder.values().stream().flatMap(p -> p.values().stream()).filter(p -> p.getType() == type).forEach(t -> for (Map<PunishmentType, PunishmentTask> punishments : _holder.values())
{ {
t.stopPunishment(); for (PunishmentTask task : punishments.values())
final String key = String.valueOf(t.getKey()); {
final Map<PunishmentType, PunishmentTask> punishments = _holder.get(key); if (task.getType() == type)
punishments.remove(t.getType()); {
task.stopPunishment();
final String key = String.valueOf(task.getKey());
punishments.remove(task.getType());
if (punishments.isEmpty()) if (punishments.isEmpty())
{ {
_holder.remove(key); _holder.remove(key);
} }
}); }
}
}
} }
/** /**

View File

@ -37,8 +37,7 @@ public class PunishmentHolder
{ {
if (!task.isExpired()) if (!task.isExpired())
{ {
final String key = String.valueOf(task.getKey()); _holder.computeIfAbsent(String.valueOf(task.getKey()), k -> new ConcurrentHashMap<>()).put(task.getType(), task);
_holder.computeIfAbsent(key, k -> new ConcurrentHashMap<>()).put(task.getType(), task);
} }
} }
@ -63,17 +62,22 @@ public class PunishmentHolder
public void stopPunishment(PunishmentType type) public void stopPunishment(PunishmentType type)
{ {
_holder.values().stream().flatMap(p -> p.values().stream()).filter(p -> p.getType() == type).forEach(t -> for (Map<PunishmentType, PunishmentTask> punishments : _holder.values())
{ {
t.stopPunishment(); for (PunishmentTask task : punishments.values())
final String key = String.valueOf(t.getKey()); {
final Map<PunishmentType, PunishmentTask> punishments = _holder.get(key); if (task.getType() == type)
punishments.remove(t.getType()); {
task.stopPunishment();
final String key = String.valueOf(task.getKey());
punishments.remove(task.getType());
if (punishments.isEmpty()) if (punishments.isEmpty())
{ {
_holder.remove(key); _holder.remove(key);
} }
}); }
}
}
} }
/** /**

View File

@ -37,8 +37,7 @@ public class PunishmentHolder
{ {
if (!task.isExpired()) if (!task.isExpired())
{ {
final String key = String.valueOf(task.getKey()); _holder.computeIfAbsent(String.valueOf(task.getKey()), k -> new ConcurrentHashMap<>()).put(task.getType(), task);
_holder.computeIfAbsent(key, k -> new ConcurrentHashMap<>()).put(task.getType(), task);
} }
} }
@ -63,17 +62,22 @@ public class PunishmentHolder
public void stopPunishment(PunishmentType type) public void stopPunishment(PunishmentType type)
{ {
_holder.values().stream().flatMap(p -> p.values().stream()).filter(p -> p.getType() == type).forEach(t -> for (Map<PunishmentType, PunishmentTask> punishments : _holder.values())
{ {
t.stopPunishment(); for (PunishmentTask task : punishments.values())
final String key = String.valueOf(t.getKey()); {
final Map<PunishmentType, PunishmentTask> punishments = _holder.get(key); if (task.getType() == type)
punishments.remove(t.getType()); {
task.stopPunishment();
final String key = String.valueOf(task.getKey());
punishments.remove(task.getType());
if (punishments.isEmpty()) if (punishments.isEmpty())
{ {
_holder.remove(key); _holder.remove(key);
} }
}); }
}
}
} }
/** /**

View File

@ -37,8 +37,7 @@ public class PunishmentHolder
{ {
if (!task.isExpired()) if (!task.isExpired())
{ {
final String key = String.valueOf(task.getKey()); _holder.computeIfAbsent(String.valueOf(task.getKey()), k -> new ConcurrentHashMap<>()).put(task.getType(), task);
_holder.computeIfAbsent(key, k -> new ConcurrentHashMap<>()).put(task.getType(), task);
} }
} }
@ -63,17 +62,22 @@ public class PunishmentHolder
public void stopPunishment(PunishmentType type) public void stopPunishment(PunishmentType type)
{ {
_holder.values().stream().flatMap(p -> p.values().stream()).filter(p -> p.getType() == type).forEach(t -> for (Map<PunishmentType, PunishmentTask> punishments : _holder.values())
{ {
t.stopPunishment(); for (PunishmentTask task : punishments.values())
final String key = String.valueOf(t.getKey()); {
final Map<PunishmentType, PunishmentTask> punishments = _holder.get(key); if (task.getType() == type)
punishments.remove(t.getType()); {
task.stopPunishment();
final String key = String.valueOf(task.getKey());
punishments.remove(task.getType());
if (punishments.isEmpty()) if (punishments.isEmpty())
{ {
_holder.remove(key); _holder.remove(key);
} }
}); }
}
}
} }
/** /**

View File

@ -37,8 +37,7 @@ public class PunishmentHolder
{ {
if (!task.isExpired()) if (!task.isExpired())
{ {
final String key = String.valueOf(task.getKey()); _holder.computeIfAbsent(String.valueOf(task.getKey()), k -> new ConcurrentHashMap<>()).put(task.getType(), task);
_holder.computeIfAbsent(key, k -> new ConcurrentHashMap<>()).put(task.getType(), task);
} }
} }
@ -63,17 +62,22 @@ public class PunishmentHolder
public void stopPunishment(PunishmentType type) public void stopPunishment(PunishmentType type)
{ {
_holder.values().stream().flatMap(p -> p.values().stream()).filter(p -> p.getType() == type).forEach(t -> for (Map<PunishmentType, PunishmentTask> punishments : _holder.values())
{ {
t.stopPunishment(); for (PunishmentTask task : punishments.values())
final String key = String.valueOf(t.getKey()); {
final Map<PunishmentType, PunishmentTask> punishments = _holder.get(key); if (task.getType() == type)
punishments.remove(t.getType()); {
task.stopPunishment();
final String key = String.valueOf(task.getKey());
punishments.remove(task.getType());
if (punishments.isEmpty()) if (punishments.isEmpty())
{ {
_holder.remove(key); _holder.remove(key);
} }
}); }
}
}
} }
/** /**

View File

@ -37,8 +37,7 @@ public class PunishmentHolder
{ {
if (!task.isExpired()) if (!task.isExpired())
{ {
final String key = String.valueOf(task.getKey()); _holder.computeIfAbsent(String.valueOf(task.getKey()), k -> new ConcurrentHashMap<>()).put(task.getType(), task);
_holder.computeIfAbsent(key, k -> new ConcurrentHashMap<>()).put(task.getType(), task);
} }
} }
@ -63,17 +62,22 @@ public class PunishmentHolder
public void stopPunishment(PunishmentType type) public void stopPunishment(PunishmentType type)
{ {
_holder.values().stream().flatMap(p -> p.values().stream()).filter(p -> p.getType() == type).forEach(t -> for (Map<PunishmentType, PunishmentTask> punishments : _holder.values())
{ {
t.stopPunishment(); for (PunishmentTask task : punishments.values())
final String key = String.valueOf(t.getKey()); {
final Map<PunishmentType, PunishmentTask> punishments = _holder.get(key); if (task.getType() == type)
punishments.remove(t.getType()); {
task.stopPunishment();
final String key = String.valueOf(task.getKey());
punishments.remove(task.getType());
if (punishments.isEmpty()) if (punishments.isEmpty())
{ {
_holder.remove(key); _holder.remove(key);
} }
}); }
}
}
} }
/** /**

View File

@ -37,8 +37,7 @@ public class PunishmentHolder
{ {
if (!task.isExpired()) if (!task.isExpired())
{ {
final String key = String.valueOf(task.getKey()); _holder.computeIfAbsent(String.valueOf(task.getKey()), k -> new ConcurrentHashMap<>()).put(task.getType(), task);
_holder.computeIfAbsent(key, k -> new ConcurrentHashMap<>()).put(task.getType(), task);
} }
} }
@ -63,17 +62,22 @@ public class PunishmentHolder
public void stopPunishment(PunishmentType type) public void stopPunishment(PunishmentType type)
{ {
_holder.values().stream().flatMap(p -> p.values().stream()).filter(p -> p.getType() == type).forEach(t -> for (Map<PunishmentType, PunishmentTask> punishments : _holder.values())
{ {
t.stopPunishment(); for (PunishmentTask task : punishments.values())
final String key = String.valueOf(t.getKey()); {
final Map<PunishmentType, PunishmentTask> punishments = _holder.get(key); if (task.getType() == type)
punishments.remove(t.getType()); {
task.stopPunishment();
final String key = String.valueOf(task.getKey());
punishments.remove(task.getType());
if (punishments.isEmpty()) if (punishments.isEmpty())
{ {
_holder.remove(key); _holder.remove(key);
} }
}); }
}
}
} }
/** /**

View File

@ -37,8 +37,7 @@ public class PunishmentHolder
{ {
if (!task.isExpired()) if (!task.isExpired())
{ {
final String key = String.valueOf(task.getKey()); _holder.computeIfAbsent(String.valueOf(task.getKey()), k -> new ConcurrentHashMap<>()).put(task.getType(), task);
_holder.computeIfAbsent(key, k -> new ConcurrentHashMap<>()).put(task.getType(), task);
} }
} }
@ -63,17 +62,22 @@ public class PunishmentHolder
public void stopPunishment(PunishmentType type) public void stopPunishment(PunishmentType type)
{ {
_holder.values().stream().flatMap(p -> p.values().stream()).filter(p -> p.getType() == type).forEach(t -> for (Map<PunishmentType, PunishmentTask> punishments : _holder.values())
{ {
t.stopPunishment(); for (PunishmentTask task : punishments.values())
final String key = String.valueOf(t.getKey()); {
final Map<PunishmentType, PunishmentTask> punishments = _holder.get(key); if (task.getType() == type)
punishments.remove(t.getType()); {
task.stopPunishment();
final String key = String.valueOf(task.getKey());
punishments.remove(task.getType());
if (punishments.isEmpty()) if (punishments.isEmpty())
{ {
_holder.remove(key); _holder.remove(key);
} }
}); }
}
}
} }
/** /**

View File

@ -37,8 +37,7 @@ public class PunishmentHolder
{ {
if (!task.isExpired()) if (!task.isExpired())
{ {
final String key = String.valueOf(task.getKey()); _holder.computeIfAbsent(String.valueOf(task.getKey()), k -> new ConcurrentHashMap<>()).put(task.getType(), task);
_holder.computeIfAbsent(key, k -> new ConcurrentHashMap<>()).put(task.getType(), task);
} }
} }
@ -63,17 +62,22 @@ public class PunishmentHolder
public void stopPunishment(PunishmentType type) public void stopPunishment(PunishmentType type)
{ {
_holder.values().stream().flatMap(p -> p.values().stream()).filter(p -> p.getType() == type).forEach(t -> for (Map<PunishmentType, PunishmentTask> punishments : _holder.values())
{ {
t.stopPunishment(); for (PunishmentTask task : punishments.values())
final String key = String.valueOf(t.getKey()); {
final Map<PunishmentType, PunishmentTask> punishments = _holder.get(key); if (task.getType() == type)
punishments.remove(t.getType()); {
task.stopPunishment();
final String key = String.valueOf(task.getKey());
punishments.remove(task.getType());
if (punishments.isEmpty()) if (punishments.isEmpty())
{ {
_holder.remove(key); _holder.remove(key);
} }
}); }
}
}
} }
/** /**

View File

@ -48,10 +48,8 @@ public class PunishmentHolder
public void stopPunishment(PunishmentTask task) public void stopPunishment(PunishmentTask task)
{ {
final String key = String.valueOf(task.getKey()); final String key = String.valueOf(task.getKey());
if (!_holder.containsKey(key)) if (_holder.containsKey(key))
{ {
return;
}
task.stopPunishment(); task.stopPunishment();
final Map<PunishmentType, PunishmentTask> punishments = _holder.get(key); final Map<PunishmentType, PunishmentTask> punishments = _holder.get(key);
punishments.remove(task.getType()); punishments.remove(task.getType());
@ -60,6 +58,7 @@ public class PunishmentHolder
_holder.remove(key); _holder.remove(key);
} }
} }
}
/** /**
* @param key * @param key
@ -78,6 +77,10 @@ public class PunishmentHolder
*/ */
public PunishmentTask getPunishment(String key, PunishmentType type) public PunishmentTask getPunishment(String key, PunishmentType type)
{ {
return _holder.containsKey(key) ? _holder.get(key).get(type) : null; if (_holder.containsKey(key))
{
return _holder.get(key).get(type);
}
return null;
} }
} }

View File

@ -48,10 +48,8 @@ public class PunishmentHolder
public void stopPunishment(PunishmentTask task) public void stopPunishment(PunishmentTask task)
{ {
final String key = String.valueOf(task.getKey()); final String key = String.valueOf(task.getKey());
if (!_holder.containsKey(key)) if (_holder.containsKey(key))
{ {
return;
}
task.stopPunishment(); task.stopPunishment();
final Map<PunishmentType, PunishmentTask> punishments = _holder.get(key); final Map<PunishmentType, PunishmentTask> punishments = _holder.get(key);
punishments.remove(task.getType()); punishments.remove(task.getType());
@ -60,6 +58,7 @@ public class PunishmentHolder
_holder.remove(key); _holder.remove(key);
} }
} }
}
/** /**
* @param key * @param key
@ -78,6 +77,10 @@ public class PunishmentHolder
*/ */
public PunishmentTask getPunishment(String key, PunishmentType type) public PunishmentTask getPunishment(String key, PunishmentType type)
{ {
return _holder.containsKey(key) ? _holder.get(key).get(type) : null; if (_holder.containsKey(key))
{
return _holder.get(key).get(type);
}
return null;
} }
} }

View File

@ -48,10 +48,8 @@ public class PunishmentHolder
public void stopPunishment(PunishmentTask task) public void stopPunishment(PunishmentTask task)
{ {
final String key = String.valueOf(task.getKey()); final String key = String.valueOf(task.getKey());
if (!_holder.containsKey(key)) if (_holder.containsKey(key))
{ {
return;
}
task.stopPunishment(); task.stopPunishment();
final Map<PunishmentType, PunishmentTask> punishments = _holder.get(key); final Map<PunishmentType, PunishmentTask> punishments = _holder.get(key);
punishments.remove(task.getType()); punishments.remove(task.getType());
@ -60,6 +58,7 @@ public class PunishmentHolder
_holder.remove(key); _holder.remove(key);
} }
} }
}
/** /**
* @param key * @param key
@ -78,6 +77,10 @@ public class PunishmentHolder
*/ */
public PunishmentTask getPunishment(String key, PunishmentType type) public PunishmentTask getPunishment(String key, PunishmentType type)
{ {
return _holder.containsKey(key) ? _holder.get(key).get(type) : null; if (_holder.containsKey(key))
{
return _holder.get(key).get(type);
}
return null;
} }
} }

View File

@ -37,8 +37,7 @@ public class PunishmentHolder
{ {
if (!task.isExpired()) if (!task.isExpired())
{ {
final String key = String.valueOf(task.getKey()); _holder.computeIfAbsent(String.valueOf(task.getKey()), k -> new ConcurrentHashMap<>()).put(task.getType(), task);
_holder.computeIfAbsent(key, k -> new ConcurrentHashMap<>()).put(task.getType(), task);
} }
} }
@ -63,17 +62,22 @@ public class PunishmentHolder
public void stopPunishment(PunishmentType type) public void stopPunishment(PunishmentType type)
{ {
_holder.values().stream().flatMap(p -> p.values().stream()).filter(p -> p.getType() == type).forEach(t -> for (Map<PunishmentType, PunishmentTask> punishments : _holder.values())
{ {
t.stopPunishment(); for (PunishmentTask task : punishments.values())
final String key = String.valueOf(t.getKey()); {
final Map<PunishmentType, PunishmentTask> punishments = _holder.get(key); if (task.getType() == type)
punishments.remove(t.getType()); {
task.stopPunishment();
final String key = String.valueOf(task.getKey());
punishments.remove(task.getType());
if (punishments.isEmpty()) if (punishments.isEmpty())
{ {
_holder.remove(key); _holder.remove(key);
} }
}); }
}
}
} }
/** /**

View File

@ -37,8 +37,7 @@ public class PunishmentHolder
{ {
if (!task.isExpired()) if (!task.isExpired())
{ {
final String key = String.valueOf(task.getKey()); _holder.computeIfAbsent(String.valueOf(task.getKey()), k -> new ConcurrentHashMap<>()).put(task.getType(), task);
_holder.computeIfAbsent(key, k -> new ConcurrentHashMap<>()).put(task.getType(), task);
} }
} }
@ -63,17 +62,22 @@ public class PunishmentHolder
public void stopPunishment(PunishmentType type) public void stopPunishment(PunishmentType type)
{ {
_holder.values().stream().flatMap(p -> p.values().stream()).filter(p -> p.getType() == type).forEach(t -> for (Map<PunishmentType, PunishmentTask> punishments : _holder.values())
{ {
t.stopPunishment(); for (PunishmentTask task : punishments.values())
final String key = String.valueOf(t.getKey()); {
final Map<PunishmentType, PunishmentTask> punishments = _holder.get(key); if (task.getType() == type)
punishments.remove(t.getType()); {
task.stopPunishment();
final String key = String.valueOf(task.getKey());
punishments.remove(task.getType());
if (punishments.isEmpty()) if (punishments.isEmpty())
{ {
_holder.remove(key); _holder.remove(key);
} }
}); }
}
}
} }
/** /**

View File

@ -37,8 +37,7 @@ public class PunishmentHolder
{ {
if (!task.isExpired()) if (!task.isExpired())
{ {
final String key = String.valueOf(task.getKey()); _holder.computeIfAbsent(String.valueOf(task.getKey()), k -> new ConcurrentHashMap<>()).put(task.getType(), task);
_holder.computeIfAbsent(key, k -> new ConcurrentHashMap<>()).put(task.getType(), task);
} }
} }
@ -63,17 +62,22 @@ public class PunishmentHolder
public void stopPunishment(PunishmentType type) public void stopPunishment(PunishmentType type)
{ {
_holder.values().stream().flatMap(p -> p.values().stream()).filter(p -> p.getType() == type).forEach(t -> for (Map<PunishmentType, PunishmentTask> punishments : _holder.values())
{ {
t.stopPunishment(); for (PunishmentTask task : punishments.values())
final String key = String.valueOf(t.getKey()); {
final Map<PunishmentType, PunishmentTask> punishments = _holder.get(key); if (task.getType() == type)
punishments.remove(t.getType()); {
task.stopPunishment();
final String key = String.valueOf(task.getKey());
punishments.remove(task.getType());
if (punishments.isEmpty()) if (punishments.isEmpty())
{ {
_holder.remove(key); _holder.remove(key);
} }
}); }
}
}
} }
/** /**

View File

@ -37,8 +37,7 @@ public class PunishmentHolder
{ {
if (!task.isExpired()) if (!task.isExpired())
{ {
final String key = String.valueOf(task.getKey()); _holder.computeIfAbsent(String.valueOf(task.getKey()), k -> new ConcurrentHashMap<>()).put(task.getType(), task);
_holder.computeIfAbsent(key, k -> new ConcurrentHashMap<>()).put(task.getType(), task);
} }
} }
@ -63,17 +62,22 @@ public class PunishmentHolder
public void stopPunishment(PunishmentType type) public void stopPunishment(PunishmentType type)
{ {
_holder.values().stream().flatMap(p -> p.values().stream()).filter(p -> p.getType() == type).forEach(t -> for (Map<PunishmentType, PunishmentTask> punishments : _holder.values())
{ {
t.stopPunishment(); for (PunishmentTask task : punishments.values())
final String key = String.valueOf(t.getKey()); {
final Map<PunishmentType, PunishmentTask> punishments = _holder.get(key); if (task.getType() == type)
punishments.remove(t.getType()); {
task.stopPunishment();
final String key = String.valueOf(task.getKey());
punishments.remove(task.getType());
if (punishments.isEmpty()) if (punishments.isEmpty())
{ {
_holder.remove(key); _holder.remove(key);
} }
}); }
}
}
} }
/** /**

View File

@ -37,8 +37,7 @@ public class PunishmentHolder
{ {
if (!task.isExpired()) if (!task.isExpired())
{ {
final String key = String.valueOf(task.getKey()); _holder.computeIfAbsent(String.valueOf(task.getKey()), k -> new ConcurrentHashMap<>()).put(task.getType(), task);
_holder.computeIfAbsent(key, k -> new ConcurrentHashMap<>()).put(task.getType(), task);
} }
} }
@ -63,17 +62,22 @@ public class PunishmentHolder
public void stopPunishment(PunishmentType type) public void stopPunishment(PunishmentType type)
{ {
_holder.values().stream().flatMap(p -> p.values().stream()).filter(p -> p.getType() == type).forEach(t -> for (Map<PunishmentType, PunishmentTask> punishments : _holder.values())
{ {
t.stopPunishment(); for (PunishmentTask task : punishments.values())
final String key = String.valueOf(t.getKey()); {
final Map<PunishmentType, PunishmentTask> punishments = _holder.get(key); if (task.getType() == type)
punishments.remove(t.getType()); {
task.stopPunishment();
final String key = String.valueOf(task.getKey());
punishments.remove(task.getType());
if (punishments.isEmpty()) if (punishments.isEmpty())
{ {
_holder.remove(key); _holder.remove(key);
} }
}); }
}
}
} }
/** /**

View File

@ -37,8 +37,7 @@ public class PunishmentHolder
{ {
if (!task.isExpired()) if (!task.isExpired())
{ {
final String key = String.valueOf(task.getKey()); _holder.computeIfAbsent(String.valueOf(task.getKey()), k -> new ConcurrentHashMap<>()).put(task.getType(), task);
_holder.computeIfAbsent(key, k -> new ConcurrentHashMap<>()).put(task.getType(), task);
} }
} }
@ -63,17 +62,22 @@ public class PunishmentHolder
public void stopPunishment(PunishmentType type) public void stopPunishment(PunishmentType type)
{ {
_holder.values().stream().flatMap(p -> p.values().stream()).filter(p -> p.getType() == type).forEach(t -> for (Map<PunishmentType, PunishmentTask> punishments : _holder.values())
{ {
t.stopPunishment(); for (PunishmentTask task : punishments.values())
final String key = String.valueOf(t.getKey()); {
final Map<PunishmentType, PunishmentTask> punishments = _holder.get(key); if (task.getType() == type)
punishments.remove(t.getType()); {
task.stopPunishment();
final String key = String.valueOf(task.getKey());
punishments.remove(task.getType());
if (punishments.isEmpty()) if (punishments.isEmpty())
{ {
_holder.remove(key); _holder.remove(key);
} }
}); }
}
}
} }
/** /**

View File

@ -37,8 +37,7 @@ public class PunishmentHolder
{ {
if (!task.isExpired()) if (!task.isExpired())
{ {
final String key = String.valueOf(task.getKey()); _holder.computeIfAbsent(String.valueOf(task.getKey()), k -> new ConcurrentHashMap<>()).put(task.getType(), task);
_holder.computeIfAbsent(key, k -> new ConcurrentHashMap<>()).put(task.getType(), task);
} }
} }
@ -63,17 +62,22 @@ public class PunishmentHolder
public void stopPunishment(PunishmentType type) public void stopPunishment(PunishmentType type)
{ {
_holder.values().stream().flatMap(p -> p.values().stream()).filter(p -> p.getType() == type).forEach(t -> for (Map<PunishmentType, PunishmentTask> punishments : _holder.values())
{ {
t.stopPunishment(); for (PunishmentTask task : punishments.values())
final String key = String.valueOf(t.getKey()); {
final Map<PunishmentType, PunishmentTask> punishments = _holder.get(key); if (task.getType() == type)
punishments.remove(t.getType()); {
task.stopPunishment();
final String key = String.valueOf(task.getKey());
punishments.remove(task.getType());
if (punishments.isEmpty()) if (punishments.isEmpty())
{ {
_holder.remove(key); _holder.remove(key);
} }
}); }
}
}
} }
/** /**

View File

@ -37,8 +37,7 @@ public class PunishmentHolder
{ {
if (!task.isExpired()) if (!task.isExpired())
{ {
final String key = String.valueOf(task.getKey()); _holder.computeIfAbsent(String.valueOf(task.getKey()), k -> new ConcurrentHashMap<>()).put(task.getType(), task);
_holder.computeIfAbsent(key, k -> new ConcurrentHashMap<>()).put(task.getType(), task);
} }
} }
@ -63,17 +62,22 @@ public class PunishmentHolder
public void stopPunishment(PunishmentType type) public void stopPunishment(PunishmentType type)
{ {
_holder.values().stream().flatMap(p -> p.values().stream()).filter(p -> p.getType() == type).forEach(t -> for (Map<PunishmentType, PunishmentTask> punishments : _holder.values())
{ {
t.stopPunishment(); for (PunishmentTask task : punishments.values())
final String key = String.valueOf(t.getKey()); {
final Map<PunishmentType, PunishmentTask> punishments = _holder.get(key); if (task.getType() == type)
punishments.remove(t.getType()); {
task.stopPunishment();
final String key = String.valueOf(task.getKey());
punishments.remove(task.getType());
if (punishments.isEmpty()) if (punishments.isEmpty())
{ {
_holder.remove(key); _holder.remove(key);
} }
}); }
}
}
} }
/** /**

View File

@ -37,8 +37,7 @@ public class PunishmentHolder
{ {
if (!task.isExpired()) if (!task.isExpired())
{ {
final String key = String.valueOf(task.getKey()); _holder.computeIfAbsent(String.valueOf(task.getKey()), k -> new ConcurrentHashMap<>()).put(task.getType(), task);
_holder.computeIfAbsent(key, k -> new ConcurrentHashMap<>()).put(task.getType(), task);
} }
} }
@ -63,17 +62,22 @@ public class PunishmentHolder
public void stopPunishment(PunishmentType type) public void stopPunishment(PunishmentType type)
{ {
_holder.values().stream().flatMap(p -> p.values().stream()).filter(p -> p.getType() == type).forEach(t -> for (Map<PunishmentType, PunishmentTask> punishments : _holder.values())
{ {
t.stopPunishment(); for (PunishmentTask task : punishments.values())
final String key = String.valueOf(t.getKey()); {
final Map<PunishmentType, PunishmentTask> punishments = _holder.get(key); if (task.getType() == type)
punishments.remove(t.getType()); {
task.stopPunishment();
final String key = String.valueOf(task.getKey());
punishments.remove(task.getType());
if (punishments.isEmpty()) if (punishments.isEmpty())
{ {
_holder.remove(key); _holder.remove(key);
} }
}); }
}
}
} }
/** /**

View File

@ -37,8 +37,7 @@ public class PunishmentHolder
{ {
if (!task.isExpired()) if (!task.isExpired())
{ {
final String key = String.valueOf(task.getKey()); _holder.computeIfAbsent(String.valueOf(task.getKey()), k -> new ConcurrentHashMap<>()).put(task.getType(), task);
_holder.computeIfAbsent(key, k -> new ConcurrentHashMap<>()).put(task.getType(), task);
} }
} }
@ -63,17 +62,22 @@ public class PunishmentHolder
public void stopPunishment(PunishmentType type) public void stopPunishment(PunishmentType type)
{ {
_holder.values().stream().flatMap(p -> p.values().stream()).filter(p -> p.getType() == type).forEach(t -> for (Map<PunishmentType, PunishmentTask> punishments : _holder.values())
{ {
t.stopPunishment(); for (PunishmentTask task : punishments.values())
final String key = String.valueOf(t.getKey()); {
final Map<PunishmentType, PunishmentTask> punishments = _holder.get(key); if (task.getType() == type)
punishments.remove(t.getType()); {
task.stopPunishment();
final String key = String.valueOf(task.getKey());
punishments.remove(task.getType());
if (punishments.isEmpty()) if (punishments.isEmpty())
{ {
_holder.remove(key); _holder.remove(key);
} }
}); }
}
}
} }
/** /**

View File

@ -37,8 +37,7 @@ public class PunishmentHolder
{ {
if (!task.isExpired()) if (!task.isExpired())
{ {
final String key = String.valueOf(task.getKey()); _holder.computeIfAbsent(String.valueOf(task.getKey()), k -> new ConcurrentHashMap<>()).put(task.getType(), task);
_holder.computeIfAbsent(key, k -> new ConcurrentHashMap<>()).put(task.getType(), task);
} }
} }
@ -63,17 +62,22 @@ public class PunishmentHolder
public void stopPunishment(PunishmentType type) public void stopPunishment(PunishmentType type)
{ {
_holder.values().stream().flatMap(p -> p.values().stream()).filter(p -> p.getType() == type).forEach(t -> for (Map<PunishmentType, PunishmentTask> punishments : _holder.values())
{ {
t.stopPunishment(); for (PunishmentTask task : punishments.values())
final String key = String.valueOf(t.getKey()); {
final Map<PunishmentType, PunishmentTask> punishments = _holder.get(key); if (task.getType() == type)
punishments.remove(t.getType()); {
task.stopPunishment();
final String key = String.valueOf(task.getKey());
punishments.remove(task.getType());
if (punishments.isEmpty()) if (punishments.isEmpty())
{ {
_holder.remove(key); _holder.remove(key);
} }
}); }
}
}
} }
/** /**

View File

@ -37,8 +37,7 @@ public class PunishmentHolder
{ {
if (!task.isExpired()) if (!task.isExpired())
{ {
final String key = String.valueOf(task.getKey()); _holder.computeIfAbsent(String.valueOf(task.getKey()), k -> new ConcurrentHashMap<>()).put(task.getType(), task);
_holder.computeIfAbsent(key, k -> new ConcurrentHashMap<>()).put(task.getType(), task);
} }
} }
@ -63,17 +62,22 @@ public class PunishmentHolder
public void stopPunishment(PunishmentType type) public void stopPunishment(PunishmentType type)
{ {
_holder.values().stream().flatMap(p -> p.values().stream()).filter(p -> p.getType() == type).forEach(t -> for (Map<PunishmentType, PunishmentTask> punishments : _holder.values())
{ {
t.stopPunishment(); for (PunishmentTask task : punishments.values())
final String key = String.valueOf(t.getKey()); {
final Map<PunishmentType, PunishmentTask> punishments = _holder.get(key); if (task.getType() == type)
punishments.remove(t.getType()); {
task.stopPunishment();
final String key = String.valueOf(task.getKey());
punishments.remove(task.getType());
if (punishments.isEmpty()) if (punishments.isEmpty())
{ {
_holder.remove(key); _holder.remove(key);
} }
}); }
}
}
} }
/** /**

View File

@ -37,8 +37,7 @@ public class PunishmentHolder
{ {
if (!task.isExpired()) if (!task.isExpired())
{ {
final String key = String.valueOf(task.getKey()); _holder.computeIfAbsent(String.valueOf(task.getKey()), k -> new ConcurrentHashMap<>()).put(task.getType(), task);
_holder.computeIfAbsent(key, k -> new ConcurrentHashMap<>()).put(task.getType(), task);
} }
} }
@ -63,17 +62,22 @@ public class PunishmentHolder
public void stopPunishment(PunishmentType type) public void stopPunishment(PunishmentType type)
{ {
_holder.values().stream().flatMap(p -> p.values().stream()).filter(p -> p.getType() == type).forEach(t -> for (Map<PunishmentType, PunishmentTask> punishments : _holder.values())
{ {
t.stopPunishment(); for (PunishmentTask task : punishments.values())
final String key = String.valueOf(t.getKey()); {
final Map<PunishmentType, PunishmentTask> punishments = _holder.get(key); if (task.getType() == type)
punishments.remove(t.getType()); {
task.stopPunishment();
final String key = String.valueOf(task.getKey());
punishments.remove(task.getType());
if (punishments.isEmpty()) if (punishments.isEmpty())
{ {
_holder.remove(key); _holder.remove(key);
} }
}); }
}
}
} }
/** /**

View File

@ -37,8 +37,7 @@ public class PunishmentHolder
{ {
if (!task.isExpired()) if (!task.isExpired())
{ {
final String key = String.valueOf(task.getKey()); _holder.computeIfAbsent(String.valueOf(task.getKey()), k -> new ConcurrentHashMap<>()).put(task.getType(), task);
_holder.computeIfAbsent(key, k -> new ConcurrentHashMap<>()).put(task.getType(), task);
} }
} }
@ -63,17 +62,22 @@ public class PunishmentHolder
public void stopPunishment(PunishmentType type) public void stopPunishment(PunishmentType type)
{ {
_holder.values().stream().flatMap(p -> p.values().stream()).filter(p -> p.getType() == type).forEach(t -> for (Map<PunishmentType, PunishmentTask> punishments : _holder.values())
{ {
t.stopPunishment(); for (PunishmentTask task : punishments.values())
final String key = String.valueOf(t.getKey()); {
final Map<PunishmentType, PunishmentTask> punishments = _holder.get(key); if (task.getType() == type)
punishments.remove(t.getType()); {
task.stopPunishment();
final String key = String.valueOf(task.getKey());
punishments.remove(task.getType());
if (punishments.isEmpty()) if (punishments.isEmpty())
{ {
_holder.remove(key); _holder.remove(key);
} }
}); }
}
}
} }
/** /**