ImmutableFeatureDefinition implements FeatureDefinition { public static ImmutableFeatureDefinition fromJson(final JsonArray featureDefinitionEntriesAsJsonArray) { checkNotNull(featureDefinitionEntriesAsJsonArray, "JSON array containing the FeatureDefinition entries"); if (featureDefinitionEntriesAsJsonArray.isEmpty()) { throw new FeatureDefinitionEmptyException(); } final List<DefinitionIdentifier> identifiersFromJson = featureDefinitionEntriesAsJsonArray.stream() .filter(JsonValue::isString) .map(JsonValue::asString) .map(ImmutableFeatureDefinitionIdentifier::ofParsed) .collect(Collectors.toList()); return new ImmutableFeatureDefinition(identifiersFromJson); } private  ImmutableFeatureDefinition(final Collection<DefinitionIdentifier> identifiers); static ImmutableFeatureDefinition fromJson(final JsonArray featureDefinitionEntriesAsJsonArray); static Builder getBuilder(final DefinitionIdentifier firstIdentifier); @Override DefinitionIdentifier getFirstIdentifier(); @Override int getSize(); @Override Stream<DefinitionIdentifier> stream(); @Override Iterator<DefinitionIdentifier> iterator(); @Override JsonArray toJson(); @Override boolean equals(final Object o); @Override int hashCode(); @Override String toString();  }
@Test public void fromJsonOfEmptyArrayFailsWithException() { assertThatExceptionOfType(FeatureDefinitionEmptyException.class) .isThrownBy(() -> ImmutableFeatureDefinition.fromJson(JsonFactory.newArray())) .withMessage("Feature Definition must not be empty!") .withNoCause(); }