public boolean match(T realA, T realB) throws SchemaException { return matchingRule.match(realA, realB); }
private static <T> boolean equals(MatchingRule<T> matchingRule, T a, T b) throws SchemaException { if (a == null && b == null) { return true; } if (a == null || b == null) { return false; } if (matchingRule == null) { return a.equals(b); } else { return matchingRule.match(a, b); } }
public static <T> boolean equals(T a, T b, MatchingRule<T> matchingRule) throws SchemaException { if (a == null && b == null) { return true; } if (a == null || b == null) { return false; } if (matchingRule == null) { if (a instanceof byte[]) { if (b instanceof byte[]) { return Arrays.equals((byte[])a, (byte[])b); } else { return false; } } else { return a.equals(b); } } else { return matchingRule.match(a, b); } }
@Override public boolean match(PolyString a, PolyString b) throws SchemaException { return nameMatchingRule.match(a.getOrig(), b.getOrig()); }
@Override public boolean match(PolyString a, PolyString b) throws SchemaException { return nameMatchingRule.match(a.getOrig(), b.getOrig()); }
private <T> void assertNoMatch(MatchingRule<T> rule, T a, T b) throws SchemaException { assertFalse("Values '"+a+"' and '"+b+"' DOES match but they should not; rule: "+rule, rule.match(a, b)); }
public boolean hasRealValue(PrismProperty<T> property, PrismPropertyValue<T> pValue) { for (T existingRealValue: property.getRealValues()) { try { if (matchingRule.match(existingRealValue, pValue.getValue())) { // LOGGER.trace("MATCH: {} ({}) <-> {} ({}) (rule: {})", new Object[]{ // existingRealValue, existingRealValue.getClass(), pValue.getValue(), pValue.getValue().getClass(), matchingRule}); return true; } // LOGGER.trace("NO match: {} ({}) <-> {} ({}) (rule: {})", new Object[]{ // existingRealValue, existingRealValue.getClass(), pValue.getValue(), pValue.getValue().getClass(), matchingRule}); } catch (SchemaException e) { // At least one of the values is invalid. But we do not want to throw exception from // a comparison operation. That will make the system very fragile. Let's fall back to // ordinary equality mechanism instead. if (existingRealValue.equals(pValue.getValue())) { return true; } } } return false; }
private boolean matches(PrismPropertyValue<?> value1, PrismPropertyValue<?> value2, MatchingRule<?> matchingRule) { try { if (matchingRule.match(value1.getRealValue(), value2.getRealValue())) { return true; } } catch (SchemaException e) { // At least one of the values is invalid. But we do not want to throw exception from // a comparison operation. That will make the system very fragile. Let's fall back to // ordinary equality mechanism instead. if (Objects.equals(value1.getRealValue(), value2.getRealValue())) { return true; } } return false; }
private <T> void assertMatch(MatchingRule<T> rule, T a, T b) throws SchemaException { assertTrue("Values '"+a+"' and '"+b+"' does not match; rule: "+rule, rule.match(a, b)); }
public static <T> void assertSets(String message, MatchingRule<T> matchingRule, Collection<T> actualValues, Collection<T> expectedValues) throws SchemaException { assertNotNull("Null set in " + message, actualValues); assertEquals("Wrong number of values in " + message+ "; expected (real values) " +PrettyPrinter.prettyPrint(expectedValues)+"; has (pvalues) "+actualValues, expectedValues.size(), actualValues.size()); for (T actualValue: actualValues) { boolean found = false; for (T value: expectedValues) { if (matchingRule == null) { if (value.equals(actualValue)) { found = true; } } else { if (matchingRule.match(value, actualValue)) { found = true; } } } if (!found) { fail("Unexpected value "+actualValue+" in " + message + "; expected (real values) " +PrettyPrinter.prettyPrint(expectedValues)+"; has (pvalues) "+actualValues); } } }
public boolean isRealValueToAdd(PropertyDelta<T> delta, PrismPropertyValue<T> pValue) { if (delta.getValuesToAdd() == null){ return false; } for (PrismPropertyValue<T> existingPValue: delta.getValuesToAdd()) { try { if (matchingRule.match(existingPValue.getValue(), pValue.getValue())) { // LOGGER.trace("MATCH: {} ({}) <-> {} ({}) (rule: {})", new Object[]{ // existingPValue.getValue(), existingPValue.getValue().getClass(), pValue.getValue(), pValue.getValue().getClass(), matchingRule}); return true; } // LOGGER.trace("NO match: {} ({}) <-> {} ({}) (rule: {})", new Object[]{ // existingPValue.getValue(), existingPValue.getValue().getClass(), pValue.getValue(), pValue.getValue().getClass(), matchingRule}); } catch (SchemaException e) { // At least one of the values is invalid. But we do not want to throw exception from // a comparison operation. That will make the system very fragile. Let's fall back to // ordinary equality mechanism instead. if (existingPValue.getValue().equals(pValue.getValue())) { return true; } } } return false; }
return matchingRule.match(thisRealValue, otherRealValue); } catch (SchemaException e) {
private boolean matches(ResourceAttribute<?> identifier, ResourceAttribute<?> attributeToMatch, MatchingRuleRegistry matchingRuleRegistry) throws SchemaException { if (!identifier.getElementName().equals(attributeToMatch.getElementName())) { return false; } RefinedAttributeDefinition rAttrDef = rOcDef.findAttributeDefinition(identifier.getElementName()); QName matchingRuleQName = rAttrDef.getMatchingRuleQName(); if (matchingRuleQName == null || matchingRuleRegistry == null) { return identifier.equals(attributeToMatch, EquivalenceStrategy.REAL_VALUE); } MatchingRule<Object> matchingRule = matchingRuleRegistry.getMatchingRule(matchingRuleQName, rAttrDef.getTypeName()); return matchingRule.match(identifier.getRealValue(), attributeToMatch.getRealValue()); }
break; } else if (nameMatchingRule.match(username, idProp.getRealValue())) { found = true; break;
break; } else if (nameMatchingRule.match(username, idProp.getRealValue())) { found = true; break;