title: org.eclipse.core.runtime.AssertionFailedException: assertion failed: in TreeViewer
body: <p>I am trying to learn Treeviewer. But, while running the code, I am getting an error while executing the line - </p>
  
  <pre><code>treeViewer.setContentProvider(new AddressContentProvider());
  </code></pre>
  
  <p>Below is the whole code I have created for View-</p>
  
  <pre><code>public class ViewPart1 extends ViewPart {
  
  public static final String ID = "HelloWorld.view1";
  TreeViewer treeViewer;
  
  public ViewPart1() {
      // TODO Auto-generated constructor stub
  }
  
  @Override
  public void createPartControl(Composite parent) {
      Tree addressTree = new Tree(parent, SWT.BORDER | SWT.H_SCROLL
              | SWT.V_SCROLL);
      addressTree.setHeaderVisible(true);
  
      TreeColumn column1 = new TreeColumn(addressTree, SWT.LEFT);
      addressTree.setLinesVisible(true);
      column1.setAlignment(SWT.LEFT);
      column1.setText("Land/Stadt");
      column1.setWidth(160);
      TreeColumn column2 = new TreeColumn(addressTree, SWT.RIGHT);
      column2.setAlignment(SWT.LEFT);
      column2.setText("Person");
      column2.setWidth(100);
      TreeColumn column3 = new TreeColumn(addressTree, SWT.RIGHT);
      column3.setAlignment(SWT.LEFT);
      column3.setText("m/w");
      column3.setWidth(35);
  
      treeViewer = new TreeViewer(addressTree);
      treeViewer.setContentProvider(new AddressContentProvider());
      treeViewer.setLabelProvider(new TableLabelProvider());
      List&lt;City&gt; cities = new ArrayList&lt;City&gt;();
      cities.add(new City());
      treeViewer.setInput(cities);
      treeViewer.expandAll();
  
  }
  
  @Override
  public void setFocus() {
      // TODO Auto-generated method stub
  
  }
  }
  
  My AddressContentProvider Class looks like this -
  
      public class AddressContentProvider implements IContentProvider {
      public Object[] getChildren(Object parentElement) {
          if (parentElement instanceof List)
              return ((List&lt;?&gt;) parentElement).toArray();
          if (parentElement instanceof City)
              return ((City) parentElement).getStreets();
          if (parentElement instanceof Street)
              return ((Street) parentElement).getHouses();
          return new Object[0];
      }
  
      public Object getParent(Object element) {
          if (element instanceof Street)
              return ((Street) element).city;
          if (element instanceof House)
              return ((House) element).street;
          return null;
      }
  
      public boolean hasChildren(Object element) {
          if (element instanceof List)
              return ((List&lt;?&gt;) element).size() &gt; 0;
          if (element instanceof City)
              return ((City) element).getStreets().length &gt; 0;
          if (element instanceof Street)
              return ((Street) element).getHouses().length &gt; 0;
          return false;
      }
  
      public Object[] getElements(Object cities) {
          return getChildren(cities);
      }
  
      public void dispose() {
      }
  
      public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
      }
      }
  </code></pre>
  
  <p>When I am trying to run this , I am getting this error - </p>
  
  <pre><code>    !ENTRY org.eclipse.e4.ui.workbench 4 0 2015-08-27 10:10:25.121
  !MESSAGE 
  !STACK 0
  org.eclipse.core.runtime.AssertionFailedException: assertion failed: 
      at org.eclipse.core.runtime.Assert.isTrue(Assert.java:110)
      at org.eclipse.core.runtime.Assert.isTrue(Assert.java:96)
      at org.eclipse.jface.viewers.AbstractTreeViewer.assertContentProviderType(AbstractTreeViewer.java:2385)
      at org.eclipse.jface.viewers.TreeViewer.assertContentProviderType(TreeViewer.java:345)...
  </code></pre>
  
  <p>What can be the probable reason?</p>
  
  <p>Edit: When I write AddressContentProvider class inside view class, it works perfectly fine. But, I am writing this class in some other file, it doesn't work :(</p>