1

Here's my final class.

public class ActivitiesSQL implements Activities {
  ...

  @Override
  public boolean add( Activity e ) {
    throw new UnsupportedOperationException( "Not supported yet." ); //To change body of generated methods, choose Tools | Templates.
  }

  @Override
  public boolean remove( Object o ) {
    throw new UnsupportedOperationException( "Not supported yet." ); //To change body of generated methods, choose Tools | Templates.
  }
}

public interface Activities extends Repository<Activity, ActivityId> {
    ...
}

public interface Repository<T, ID> extends Set<T> {

  public abstract T findById( ID id );
}

What I'm trying to understand is why the generated code is remove( Object... and add( Activity ...). Why isn't it remove( Activity ... )?

xenoterracide
  • 16,274
  • 24
  • 118
  • 243

1 Answers1

3

Assuming the Set you are extending is java.util.Set, the argument to remove() is type Object because that's the way it's defined in java.util.Set.

You could define your own remove(T) in Repository and delegate to Set#remove() if you wanted to, but then it wouldn't be an @Override any more.

See also this answer and this answer

Community
  • 1
  • 1
Jim Garrison
  • 85,615
  • 20
  • 155
  • 190