4 Replies Latest reply: Mar 2, 2010 1:50 PM by DrClap RSS

    erasure error

    843793
      Hi all,

      I have the following problem, I want to convert some types in an util class.

      public static List<ProductVo> entity2vo(List<ProductEntity> entities) {
      // convert code here
      }

      public static List<ClientVo> entity2vo(List<ClientEntity> entities) {
      // convert code here
      }

      But I get the following error message: Method entity2vo(List<ClientEntity>) has the same erasure entity2vo(List<E>) as another method in type Vo2EntityConverter

      How can I solve this?

      Bart
        • 1. Re: erasure error
          843793
          You can't have two methods that are different only in a generic type argument.

          Either change the names or make them take a single object each.
          • 2. Re: erasure error
            843793
            I don't want to change the method name. Is there maybe another solution?
            • 3. Re: erasure error
              843793
              bartdepauw wrote:
              I don't want to change the method name.
              Why not?
              Is there maybe another solution?
              The other solution is to change the arguments so that they are different in something other than the generic type only.

              This means either changing it to take a single ProductEntity/ClientEntity only or to produce a special ProductEntityList/ClientEntityList (but that's a terrible idea).
              • 4. Re: erasure error
                DrClap
                bartdepauw wrote:
                I don't want to change the method name. Is there maybe another solution?
                You could make them be methods (with the same name) of different classes.