}
private static void ensureDecoratorMetContract(final FacetDecorator facetDecorator, final Facet decoratingFacet,
final Class<? extends Facet> facetType, final FacetHolder originalFacetHolder) {
if (decoratingFacet.facetType() != facetType) {
throw new MetaModelException(
MessageFormat
.format(
"Problem with facet decorator '{0}'; inconsistent decorating facetType() for {1}; was {2} but expectected facetType() of {3}",
facetDecorator.getClass().getName(), decoratingFacet.getClass().getName(), decoratingFacet
.facetType().getName(), facetType.getName()));
}
final Facet facetForFacetType = originalFacetHolder.getFacet(decoratingFacet.facetType());
if (facetForFacetType != decoratingFacet) {
throw new MetaModelException(MessageFormat.format(
"Problem with facet decorator '{0}'; has not replaced original facet for facetType() of {1}",
facetDecorator.getClass().getName(), facetType.getName()));
}
}