@Override public boolean supports(TherianContext context, Add<?, ? extends Collection<?>> add) { // cannot add to immutable types if (context.eval(ImmutableCheck.of(add.getTargetPosition())).booleanValue()) { return false; } if (!TypeUtils.isAssignable(add.getTargetPosition().getType(), Collection.class)) { return false; } final Type targetElementType = TypeUtils.unrollVariables( TypeUtils.getTypeArguments(add.getTargetPosition().getType(), Collection.class), Collection.class.getTypeParameters()[0]); if (targetElementType == null) { // raw collection return true; } return TypeUtils.isAssignable(add.getSourcePosition().getType(), targetElementType); }
public boolean supports(Copy<?, ?> operation) { return operation.getTargetPosition() instanceof Position.Writable && TherianContext.getRequiredInstance() .eval(ImmutableCheck.of(operation.getTargetPosition())) .booleanValue(); }