/** * Builds a {@link MetadataEntity} from the builder. * * @return {@link MetadataEntity} from the builder * @throws IllegalArgumentException if the key is a CDAP entity and the MetadataEntity is not correct to represent * the CDAP entity */ public MetadataEntity build() { if (parts.isEmpty()) { throw new IllegalArgumentException("key-value pair must be specified"); } if (type == null) { // traverse till the last key and make that the type parts.keySet().forEach(x -> type = x); } validateHierarchy(); return new MetadataEntity(new LinkedHashMap<>(parts), type); }