Correct way to get field definitions for entity types
Think this is an OOP question... so the correct answer is to switch by the type of the instance. In PHP you do this with &quot;instanceof&quot;, like here in MappingTest.php:
protected function filterNumericFields(&amp;$fields) {
    foreach ($this-&gt;view-&gt;field as $id =&gt; $field) {
      if (!($field instanceof NumericField)) {
        unset($fields[$id]);
      }
    }
  }

Note: dpm is bad with nested objects... you should set up a debugger like xdebug.
Another Note: Each content entity has a getFieldDefinitions method:
   /**
   * {@inheritdoc}
   */
  public function getFieldDefinitions() {
    if (!isset($this-&gt;fieldDefinitions)) {
      $this-&gt;fieldDefinitions = \Drupal::service('entity_field.manager')-&gt;getFieldDefinitions($this-&gt;entityTypeId, $this-&gt;bundle());
    }
    return $this-&gt;fieldDefinitions;
  }