title: Hamcrest Matcher compilation difference between Eclipse and javac
body: <p>I am trying to make use of a custom matcher from hamcrest within the hasItem matcher</p>
  
  <pre><code>  @Test
    public void populatesChildCompanies() {
      final long firstChildId = 2;
      final String firstChildName = "jim";
      final long secondChildId = 3;
      final String secondChildName = "adam";
      final List&lt;Company&gt; childCompanies = asList(createCompanyForRelation(firstChildCid, firstChildName),
          createCompanyForRelation(secondChildCid, secondChildName));
      company.getChildCompanies().addAll(childCompanies);
  
      final CompanyOverview companyOverview = new CompanyOverview(company);
  
      assertThat(companyOverview.getChildCompanies(), hasItem(companyRelation(firstChildName, firstChildId)));
      assertThat(companyOverview.getChildCompanies(), hasItem(companyRelation(secondChildName, secondChildId)));
    }
  </code></pre>
  
  <p>The matcher looks like this</p>
  
  <pre><code>  public static final Matcher&lt;CompanyRelation&gt; companyRelation(final String name, final long id) {
      return new TypeSafeMatcher&lt;CompanyRelation&gt;() {
  
        @Override
        protected boolean matchesSafely(final CompanyRelation companyRelation) {
          return name.equals(companyRelation.getName()) &amp;&amp; id == companyRelation.getId();
        }
  
        @Override
        public void describeTo(final Description description) {
          description.appendText(format("a company relation with a name of %s and a CID of %s", name, id));
        }
  
        @Override
        protected void describeMismatchSafely(final CompanyRelation companyRelation, final Description description) {
          description.appendText(format("[%s, %s]", companyRelation.getName(), companyRelation.getId()));
        }
      };
    }
  </code></pre>
  
  <p>This operates just fine from within eclipse but when built with maven from command line it throws an exception:</p>
  
  <pre><code>[ERROR] CompanyOverviewTest.java:[96,4] cannot find symbol
  [ERROR] symbol  : method assertThat(java.util.List&lt;CompanyRelation&gt;,org.hamcrest.Matcher&lt;java.lang.Iterable&lt;? super java.lang.Object&gt;&gt;)
  </code></pre>
  
  <p>I know this is a type erasure problem, and that it's due to some difference between the eclipse compiler and the command line, but I am unsure of the best way to handle it.</p>