LikeConstraint implements Constraint { public boolean matchesSlaveAttributes(Collection<Attribute> attributes) { if (!lhs.equalsIgnoreCase(HOSTNAME) && attributes != null) { for (Attribute attr : attributes) { if (attr.getName().equalsIgnoreCase(lhs)) { switch (attr.getType()) { case TEXT: return this.pattern.matcher(attr.getText().getValue()).matches(); case SCALAR: return this.pattern.matcher(String.valueOf(attr.getScalar().getValue())).matches(); default: LOGGER.warn("LIKE constraint currently doesn't support Mesos slave attributes " + "of type {}. Attribute Name: {}", attr.getType(), attr.getName()); return false; } } } } return false; } LikeConstraint(String lhs, String rhsRegex); boolean isConstraintOnHostName(); boolean matchesHostName(String hostname); boolean matchesSlaveAttributes(Collection<Attribute> attributes); @Override Type getType(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode();  }
@Test public void testMatchSlaveAttributes() throws Exception { List<Attribute> attributes = Lists.newArrayList(getTextAttribute("dfs", "dfs-test")); assertTrue(constraintThree.matchesSlaveAttributes(attributes)); }