public boolean match(RequiredExecutionPlatformInstance platform) { return getType().match(platform.getType()); }
private RequiredExecutionPlatformInstance rejectIfInvalid(RequiredExecutionPlatformInstance platform) { if (platform == null) { final String error = String.format("Error in internal component instance '%s'! ('null' cannot be the required execution platform)", getQualifiedName()); throw new IllegalArgumentException(error); } if (!platform.getType().equals(this.getType().getRequiredExecutionPlatform())) { final String error = String.format("Error in internal component instance '%s'! Required execution platform has a wrong type (expected: '%s' but found '%s')", getQualifiedName(), getType().getRequiredExecutionPlatform().getQualifiedName(), platform.getType().getQualifiedName()); throw new IllegalArgumentException(error); } return platform; }
private void unlessExpectationsAreMet(ProvidedExecutionPlatformInstance provided, RequiredExecutionPlatformInstance required) { for (Property demand : required.getType().getDemands()) { Property offer = provided.getType().getOffers().get(demand.getName()); if (offer == null) { throw new IllegalArgumentException("Missing expectations: " + demand.getName()); } if (!demand.getValue().equals(offer.getValue())) { throw new IllegalArgumentException("Unmet expectation '" + demand.getName() + "' (expected + '" + demand.getValue() + "' but found: '" + offer.getValue() + "')"); } } }
@Override public void validate(Report report) { final PropertyGroup demands = getRequiredEnd().getType().getDemands(); for (Property demand : demands) { final PropertyGroup offers = getProvidedEnd().getType().getOffers(); if (!offers.isDefined(demand.getName())) { final String error = String.format("Mismatch between demands and offers! Demanded: %s, but %s is not offered", demand, demand.getName()); report.addError(error); } else { if (!offers.contains(demand)) { final Property offer = offers.get(demand.getName()); final String error = String.format("Mismatch between demands and offers!! Demanded: %s, but offered %s", demand, offer); report.addError(error); } } } }