cloudstate icon indicating copy to clipboard operation
cloudstate copied to clipboard

Missing methods to override in GSet

Open FunkyFunctor-Chris opened this issue 5 years ago • 4 comments

While working on another Scala client, I wondered if, since a GSet is supposed to be grow-only, we shouldn't also override the following methods so they throw an UnsupportedOperationException like remove does? Am I missing something?

Methods are:

  • def removeAll(c: util.Collection[_]): Boolean
  • def removeIf(filter: Predicate[_ >: T]): Boolean
  • def clear(): Unit
  • def retainAll(c: util.Collection[_]): Boolean

Proposed solution:

Add the java equivalent of the following code to io.cloudstate.javasupport.crdt.GSet

  override def removeAll(c: util.Collection[_]): Boolean =
    throw new UnsupportedOperationException(
      "Remove is not supported on a Grow-only Set.")

  override def removeIf(filter: Predicate[_ >: T]): Boolean =
    throw new UnsupportedOperationException(
      "Remove is not supported on a Grow-only Set.")

  override def clear(): Unit =
    throw new UnsupportedOperationException(
      "Remove is not supported on a Grow-only Set.")

  override def retainAll(c: util.Collection[_]): Boolean =
    throw new UnsupportedOperationException(
      "Remove is not supported on a Grow-only Set.")

FunkyFunctor-Chris avatar Feb 13 '20 01:02 FunkyFunctor-Chris

@ChristopherAndre Doesn't the default implementations of all those methods call remove at some point? Could you show me what happens if you invoke any of them?

viktorklang avatar Feb 16 '20 14:02 viktorklang

@ChristopherAndre Ping

viktorklang avatar Feb 25 '20 12:02 viktorklang

Sorry, completely slipped off my mind... I think you're right but am not sure implementations have to call remove.

FunkyFunctor-Chris avatar Mar 24 '20 19:03 FunkyFunctor-Chris

@ChristopherAndre No worries. What happens if you try to call the methods?

viktorklang avatar Mar 26 '20 00:03 viktorklang