Search code examples
javawarningssuppress-warnings

AddLinkEntry Class is a raw type. References to generic type AddLinkEntry Class<T> should be parameterized


I have the following the line which throws "AddLinkEntry is a raw type. References to generic type AddLinkEntry should be parameterized" warning

List<AddLinkEntry> addLinkCache = new ArrayList<AddLinkEntry>();

and there is the AddLinkEntry class

public class AddLinkEntry<T> {

  /**
   * Function that Adds a link between this object and given object
   */
  private IAddLinkToObjectFunctional<T> objectFunctional;

  /**
   * ID of given object
   */
  private Id id;

  /**
   * Constructs a new {AddLinkEntry<T>}.
   * 
   * @param objectFunctional
   *        Function that Adds a link between this object and given object
   * @param id
   *        ID of given object
   */
  public AddLinkEntry(IAddLinkToObjectFunctional<T> objectFunctional, Id id) {
    this.objectFunctional = objectFunctional;
    this.id = id;
  }

  /**
   * Retrieve a function that Adds a link between this object and given object
   */
  public IAddLinkToObjectFunctional<T> executeLinkage() {
    return objectFunctional;
  }

  /**
   * Retrieve an Id
   */
  public Id getId() {
    return id;
  }

  @FunctionalInterface
  public interface IAddLinkToObjectFunctional<T> {

    /**
     * Adds a link between this object and given object
     * 
     * @param objectNode a given object to link
     */
    void addLink(T objectNode);
  }
}

I would like to know what causes the warning and how to get rid of it without using suppress-warnings?


Solution

  • I think that you need to parametrized also AddLinkEntry with a type you want to store for example List<AddLinkEntry<String>> addLinkCache = new ArrayList<AddLinkEntry<String>>();