I'll file a ticket to improve this class.

On Fri, May 8, 2020 at 2:24 PM Jacob Barrett <jbarr...@pivotal.io> wrote:

>
>
> > On May 8, 2020, at 1:42 PM, Kirk Lund <kl...@pivotal.io> wrote:
> >
> > I've been using this class in geode-core mostly for tests:
> >
> > package org.apache.geode.internal.cache.util;
> >
> > import org.apache.geode.cache.execute.Execution;
> >
> > @SuppressWarnings({"unchecked", "unused"})
> > public class UncheckedUtils {
> >
> >  public static <T> T cast(Object object) {
> >    return (T) object;
> >  }
> >
> >  public static <IN, OUT, AGG> Execution<IN, OUT, AGG> cast(Execution
> > execution) {
> >    return execution;
> >  }
> > }
> >
> > The problem with an annotation is that if you have 10-20 or more mocks
> > (which happens with our code base) then that's just way too many
> > additional lines with that annotation or you end up annotating the whole
> > class or something which I think is bad. The "cast" method call is inline
> > and very small (admittedly it doesn't currently have javadocs).
>
> I like this. I would just ask that function name be “unchecked” or
> “uncheckedCast” to make it clear when reading the code using it. If the
> method is static imported, as I think it should, then cast(something(…))
> isn’t clear that its an intentional unchecked cast. Maybe that is ok… I
> guess I could be persuaded that its ok. Javadocs please!
>
> -Jake
>
>

Reply via email to