import static java.util.Objects.requireNonNull;
import com.google.common.collect.ImmutableMap;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.VarHandle;
import java.util.Map;
// Used via VarHandle
@SuppressWarnings("unused")
+ @SuppressFBWarnings(value = "UUF_UNUSED_FIELD", justification = "https://github.com/spotbugs/spotbugs/issues/2749")
private volatile ImmutableMap<Class<? extends Augmentation<T>>, Augmentation<T>> cachedAugmentations;
protected AugmentableCodecDataObject(final AbstractDataObjectCodecContext<T, ?> context,
}
@SuppressWarnings("rawtypes")
- final var optAugCtx = codecContext().possibleStreamChild((Class) augmentationType);
- if (optAugCtx.isPresent()) {
- final var augCtx = (AugmentationCodecContext<A>) optAugCtx.orElseThrow();
- // Due to binding specification not representing grouping instantiations we can end up having the same
- // augmentation applied to a grouping multiple times. While these augmentations have the same shape, they
- // are still represented by distinct binding classes and therefore we need to make sure the result matches
- // the augmentation the user is requesting -- otherwise a strict receiver would end up with a cryptic
- // ClassCastException.
- if (augmentationType.isAssignableFrom(augCtx.getBindingClass())) {
- final var augObj = augCtx.filterFrom(codecData());
- if (augObj != null) {
- return augObj;
- }
+ final var augCtx = (AugmentationCodecContext<A>) codecContext().streamChild((Class) augmentationType);
+ // Due to binding specification not representing grouping instantiations we can end up having the same
+ // augmentation applied to a grouping multiple times. While these augmentations have the same shape, they are
+ // still represented by distinct binding classes and therefore we need to make sure the result matches
+ // the augmentation the user is requesting -- otherwise a strict receiver would end up with a cryptic
+ // ClassCastException.
+ if (augCtx != null && augmentationType.isAssignableFrom(augCtx.getBindingClass())) {
+ final var augObj = augCtx.filterFrom(codecData());
+ if (augObj != null) {
+ return augObj;
}
}
return null;