package de.ddb.pdc.metadata;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

import java.util.ArrayList;

@JsonIgnoreProperties(ignoreUnknown = true)
class EntitiesResult {

  @JsonProperty
  private ArrayList<EntitiesResultList> results;

  public EntitiesResultItem getResultItem() {
    return results.get(0).getDocs().get(0);
  }
}

package de.ddb.pdc.metadata;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

import java.util.ArrayList;

@JsonIgnoreProperties(ignoreUnknown = true)
class EntitiesResult {

  @JsonProperty
  private ArrayList<EntitiesResultList> results;

  public EntitiesResultItem getResultItem() {

    if (results.size() == 0 || results.get(0).getDocs().size() == 0) {
      return null;
    } else {
      return results.get(0).getDocs().get(0);
    }
  }
}

check if size == 0, return null