/** * This method is used to combine the current {@code Collection} of meta-data associated with a * {@code DescriptorModel} with the newly added once. * * @param descModelId the identifier of the {@code DescriptorModel} * @param current the current meta-data * @param added the meta-data to be added * @throws ForwardedRuntimeException if the specified meta-data is invalid */ protected void combineMetaData( final String descModelId, final LoadedMetaData current, final IIdentifiedMetaData added) throws ForwardedRuntimeException { if (added == null) { return; } /* * We have identifiers to be added and we already have an identifier * set. * * currentDefMetaData might be null, or not. Therefore we have to * consider it. */ final Map<Object, Object> curValues = current.getIdentifiedValues(); final Map<Object, Object> addedValues = added.getIdentifiedValues(); // add the values, but make sure there is nothing modified for (final Entry<Object, Object> e : addedValues.entrySet()) { final Object k = e.getKey(); final Object v = e.getValue(); if (curValues.containsKey(k)) { final Object curValue = curValues.get(k); if (!Objects.equals(curValue, v)) { throw new ForwardedRuntimeException( MetaDataCollectionException.class, 1000, k, curValue, v); } } else { current.addValue(k, v); } } // create a new id meta-data set current.addValues(addedValues); }
/** * Adds the specified {@code Descriptor} to the cache. * * @param desc the {@code Descriptor} to be added */ public void addDescriptor(final Descriptor<?, ?, ?> desc) { final LoadedMetaData metaData = new LoadedMetaData(desc.getModelId()); metaData.addValue(desc.getId(), desc.getValue()); this.addMetaData(metaData); }