AnswerBun.com

why am I have to convert

Stack Overflow Asked by Ömer on September 12, 2020

I’m trying to make a custom key with some numbers and stuff for my BidiMap like this

package FNA.ArithmeticsTypes;

public interface ArithmeticsOperations<N>
{
   void division(N number);
   void multiplication(N number);
   
   String getValue();
   ArithmeticsOperations<N> setValue(N value);
   ArithmeticsOperations<N> setValue(int value);
   
}

But when I try to put something it require casting. Why is this type casting required?

package FNA.Repositories;

import FNA.ArithmeticsTypes.ArithmeticsOperations;
import org.apache.commons.collections4.BidiMap;
import org.apache.commons.collections4.bidimap.DualHashBidiMap;

public abstract class BidiDictionary<T extends ArithmeticsOperations<?>,E>
{
   private BidiMap<T,E> dictionary = new DualHashBidiMap<>();
   
   public void registerNewElement(E element)
   {
      if(!dictionary.containsValue(element))
      {
         dictionary.put((T) /*Problem is here*/ typeGenerator().setValue(...)), element);
      }
   }
   
   abstract T typeGenerator();
}

Add your own answers!

Related Questions

How to migrate repos from SVN to Gerrit?

0  Asked on January 7, 2021 by fresher

       

Text File Problems

1  Asked on January 7, 2021 by taco_attack

       

Is there an easy way to get out of this IF loop?

3  Asked on January 7, 2021 by matias

       

How to proxy image with Netlify Lambda

0  Asked on January 6, 2021 by xaver-fleer

         

a method that converts a daynumber into a date

4  Asked on January 6, 2021 by leenieke19

     

Rails devise cache refreshed at every request

2  Asked on January 6, 2021 by sparkle

   

How to post data to web page form and get response using php

1  Asked on January 6, 2021 by abdulrahman-mohamed

 

How to get browser name using Selenium WebDriver with Java?

5  Asked on January 6, 2021 by swathi-chowdary

   

Ask a Question

Get help from others!

© 2022 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP, SolveDir