PMD plugin integration

chore: PMD plugin integration and the respective clean-up

Signed-off-by: Leo Galambos <lg@hq.egothor.org>
This commit is contained in:
2025-07-25 13:54:03 +02:00
parent bd7bcf54a5
commit 36233ab444
5 changed files with 325 additions and 1606 deletions

View File

@@ -108,10 +108,10 @@ public final class CtxInstance implements CtxInterface {
}
// notify listeners
var list = listeners.get(key);
List<WeakReference<Listener<?>>> list = listeners.get(key);
if (list != null) {
for (var ref : list) {
var listener = ref.get();
for (WeakReference<Listener<?>> ref : list) {
Listener<?> listener = ref.get();
if (listener != null) {
@SuppressWarnings("unchecked")
Listener<T> typedListener = (Listener<T>) listener;
@@ -156,7 +156,7 @@ public final class CtxInstance implements CtxInterface {
@Override
public Object remove(Key<?> key) {
keyTypes.remove(key.name());
var removed = values.remove(key);
Object removed = values.remove(key);
listeners.remove(key);
return removed;
}
@@ -193,10 +193,10 @@ public final class CtxInstance implements CtxInterface {
*/
@Override
public <T> void removeListener(Key<T> key, Listener<T> listener) {
var list = listeners.get(key);
List<WeakReference<Listener<?>>> list = listeners.get(key);
if (list != null) {
list.removeIf(ref -> {
var l = ref.get();
Listener<?> l = ref.get();
return l == null || l.equals(listener);
});
if (list.isEmpty()) {

View File

@@ -42,19 +42,19 @@ package conflux;
* @author Leo Galambos
*/
public final class Key<T> { // NOPMD by Leo Galambos on 7/3/25, 10:29PM
private final String name;
private final Class<T> type;
private final String nameField;
private final Class<T> typeField;
private Key(String name, Class<T> type) {
this.name = name;
this.type = type;
this.nameField = name;
this.typeField = type;
}
/**
* Creates a new typed key.
*
* @param name a unique key name
* @param type the class of the key's value type
* @param name a unique key nameField
* @param type the class of the key's value typeField
* @param <T> the type
* @return a new {@code Key}
*/
@@ -68,7 +68,7 @@ public final class Key<T> { // NOPMD by Leo Galambos on 7/3/25, 10:29PM
* @return the name
*/
public String name() {
return name;
return nameField;
}
/**
@@ -77,21 +77,21 @@ public final class Key<T> { // NOPMD by Leo Galambos on 7/3/25, 10:29PM
* @return the type
*/
public Class<T> type() {
return type;
return typeField;
}
@Override
public int hashCode() {
return name.hashCode();
return nameField.hashCode();
}
@Override
public boolean equals(Object obj) {
return obj instanceof Key<?> other && name.equals(other.name);
return obj instanceof Key<?> other && nameField.equals(other.nameField);
}
@Override
public String toString() {
return "Key[" + name + ", " + type.getSimpleName() + "]";
return "Key[" + nameField + ", " + typeField.getSimpleName() + "]";
}
}