/** * Returns <tt>true</tt> iff <i>a</i> is a <i>proper</i> sub-collection of <i>b</i>, * that is, iff the cardinality of <i>e</i> in <i>a</i> is less * than or equal to the cardinality of <i>e</i> in <i>b</i>, * for each element <i>e</i> in <i>a</i>, and there is at least one * element <i>f</i> such that the cardinality of <i>f</i> in <i>b</i> * is strictly greater than the cardinality of <i>f</i> in <i>a</i>. * <p> * The implementation assumes * <ul> * <li><code>a.size()</code> and <code>b.size()</code> represent the * total cardinality of <i>a</i> and <i>b</i>, resp. </li> * <li><code>a.size() < Integer.MAXVALUE</code></li> * </ul> * * @param a the first (sub?) collection, must not be null * @param b the second (super?) collection, must not be null * @return <code>true</code> iff <i>a</i> is a <i>proper</i> sub-collection of <i>b</i> * @see #isSubCollection * @see Collection#containsAll */ public static boolean isProperSubCollection(final Collection a, final Collection b) { return (a.size() < b.size()) && CollectionUtils.isSubCollection(a,b); }
/** * Returns <tt>true</tt> iff <i>a</i> is a <i>proper</i> sub-collection of <i>b</i>, * that is, iff the cardinality of <i>e</i> in <i>a</i> is less * than or equal to the cardinality of <i>e</i> in <i>b</i>, * for each element <i>e</i> in <i>a</i>, and there is at least one * element <i>f</i> such that the cardinality of <i>f</i> in <i>b</i> * is strictly greater than the cardinality of <i>f</i> in <i>a</i>. * <p> * The implementation assumes * <ul> * <li><code>a.size()</code> and <code>b.size()</code> represent the * total cardinality of <i>a</i> and <i>b</i>, resp. </li> * <li><code>a.size() < Integer.MAXVALUE</code></li> * </ul> * * @param a the first (sub?) collection, must not be null * @param b the second (super?) collection, must not be null * @return <code>true</code> iff <i>a</i> is a <i>proper</i> sub-collection of <i>b</i> * @see #isSubCollection * @see Collection#containsAll */ public static boolean isProperSubCollection(final Collection a, final Collection b) { return (a.size() < b.size()) && CollectionUtils.isSubCollection(a,b); }
public void testIsSubCollection() { assertTrue(!CollectionUtils.isSubCollection(collectionA,collectionB)); assertTrue(!CollectionUtils.isSubCollection(collectionB,collectionA)); }
public void testIsSubCollectionOfSelf() { assertTrue(CollectionUtils.isSubCollection(collectionA,collectionA)); assertTrue(CollectionUtils.isSubCollection(collectionB,collectionB)); }
public void testIsSubCollection2() { Collection c = new ArrayList(); assertTrue(CollectionUtils.isSubCollection(c,collectionA)); assertTrue(!CollectionUtils.isSubCollection(collectionA,c)); c.add("a"); assertTrue(CollectionUtils.isSubCollection(c,collectionA)); assertTrue(!CollectionUtils.isSubCollection(collectionA,c)); c.add("b"); assertTrue(CollectionUtils.isSubCollection(c,collectionA)); assertTrue(!CollectionUtils.isSubCollection(collectionA,c)); c.add("b"); assertTrue(CollectionUtils.isSubCollection(c,collectionA)); assertTrue(!CollectionUtils.isSubCollection(collectionA,c)); c.add("c"); assertTrue(CollectionUtils.isSubCollection(c,collectionA)); assertTrue(!CollectionUtils.isSubCollection(collectionA,c)); c.add("c"); assertTrue(CollectionUtils.isSubCollection(c,collectionA)); assertTrue(!CollectionUtils.isSubCollection(collectionA,c)); c.add("c"); assertTrue(CollectionUtils.isSubCollection(c,collectionA)); assertTrue(!CollectionUtils.isSubCollection(collectionA,c)); c.add("d"); assertTrue(CollectionUtils.isSubCollection(c,collectionA)); assertTrue(!CollectionUtils.isSubCollection(collectionA,c)); c.add("d"); assertTrue(CollectionUtils.isSubCollection(c,collectionA)); assertTrue(!CollectionUtils.isSubCollection(collectionA,c)); c.add("d"); assertTrue(CollectionUtils.isSubCollection(c,collectionA));
@Override public boolean doesTargetStorageSupportDiskOffering(StoragePool destPool, String diskOfferingTags) { if (org.apache.commons.lang.StringUtils.isBlank(diskOfferingTags)) { return true; } String storagePoolTags = getStoragePoolTags(destPool); if (org.apache.commons.lang.StringUtils.isBlank(storagePoolTags)) { return false; } String[] storageTagsAsStringArray = org.apache.commons.lang.StringUtils.split(storagePoolTags, ","); String[] newDiskOfferingTagsAsStringArray = org.apache.commons.lang.StringUtils.split(diskOfferingTags, ","); return CollectionUtils.isSubCollection(Arrays.asList(newDiskOfferingTagsAsStringArray), Arrays.asList(storageTagsAsStringArray)); }
/** * Returns <tt>true</tt> iff <i>a</i> is a <i>proper</i> sub-collection of <i>b</i>, * that is, iff the cardinality of <i>e</i> in <i>a</i> is less * than or equal to the cardinality of <i>e</i> in <i>b</i>, * for each element <i>e</i> in <i>a</i>, and there is at least one * element <i>f</i> such that the cardinality of <i>f</i> in <i>b</i> * is strictly greater than the cardinality of <i>f</i> in <i>a</i>. * <p> * The implementation assumes * <ul> * <li><code>a.size()</code> and <code>b.size()</code> represent the * total cardinality of <i>a</i> and <i>b</i>, resp. </li> * <li><code>a.size() < Integer.MAXVALUE</code></li> * </ul> * * @param a the first (sub?) collection, must not be null * @param b the second (super?) collection, must not be null * @return <code>true</code> iff <i>a</i> is a <i>proper</i> sub-collection of <i>b</i> * @see #isSubCollection * @see Collection#containsAll */ public static boolean isProperSubCollection(final Collection a, final Collection b) { return (a.size() < b.size()) && CollectionUtils.isSubCollection(a,b); }
/** * Returns <tt>true</tt> iff <i>a</i> is a <i>proper</i> sub-collection of <i>b</i>, * that is, iff the cardinality of <i>e</i> in <i>a</i> is less * than or equal to the cardinality of <i>e</i> in <i>b</i>, * for each element <i>e</i> in <i>a</i>, and there is at least one * element <i>f</i> such that the cardinality of <i>f</i> in <i>b</i> * is strictly greater than the cardinality of <i>f</i> in <i>a</i>. * <p> * The implementation assumes * <ul> * <li><code>a.size()</code> and <code>b.size()</code> represent the * total cardinality of <i>a</i> and <i>b</i>, resp. </li> * <li><code>a.size() < Integer.MAXVALUE</code></li> * </ul> * * @param a the first (sub?) collection, must not be null * @param b the second (super?) collection, must not be null * @return <code>true</code> iff <i>a</i> is a <i>proper</i> sub-collection of <i>b</i> * @see #isSubCollection * @see Collection#containsAll */ public static boolean isProperSubCollection(final Collection a, final Collection b) { return (a.size() < b.size()) && CollectionUtils.isSubCollection(a,b); }
/** * Returns <tt>true</tt> iff <i>a</i> is a <i>proper</i> sub-collection of <i>b</i>, * that is, iff the cardinality of <i>e</i> in <i>a</i> is less * than or equal to the cardinality of <i>e</i> in <i>b</i>, * for each element <i>e</i> in <i>a</i>, and there is at least one * element <i>f</i> such that the cardinality of <i>f</i> in <i>b</i> * is strictly greater than the cardinality of <i>f</i> in <i>a</i>. * <p> * The implementation assumes * <ul> * <li><code>a.size()</code> and <code>b.size()</code> represent the * total cardinality of <i>a</i> and <i>b</i>, resp. </li> * <li><code>a.size() < Integer.MAXVALUE</code></li> * </ul> * * @param a the first (sub?) collection, must not be null * @param b the second (super?) collection, must not be null * @return <code>true</code> iff <i>a</i> is a <i>proper</i> sub-collection of <i>b</i> * @see #isSubCollection * @see Collection#containsAll */ public static boolean isProperSubCollection(final Collection a, final Collection b) { return (a.size() < b.size()) && CollectionUtils.isSubCollection(a,b); }
/** * Returns <tt>true</tt> iff <i>a</i> is a <i>proper</i> sub-collection of <i>b</i>, * that is, iff the cardinality of <i>e</i> in <i>a</i> is less * than or equal to the cardinality of <i>e</i> in <i>b</i>, * for each element <i>e</i> in <i>a</i>, and there is at least one * element <i>f</i> such that the cardinality of <i>f</i> in <i>b</i> * is strictly greater than the cardinality of <i>f</i> in <i>a</i>. * <p> * The implementation assumes * <ul> * <li><code>a.size()</code> and <code>b.size()</code> represent the * total cardinality of <i>a</i> and <i>b</i>, resp. </li> * <li><code>a.size() < Integer.MAXVALUE</code></li> * </ul> * * @param a the first (sub?) collection, must not be null * @param b the second (super?) collection, must not be null * @return <code>true</code> iff <i>a</i> is a <i>proper</i> sub-collection of <i>b</i> * @see #isSubCollection * @see Collection#containsAll */ public static boolean isProperSubCollection(final Collection a, final Collection b) { return (a.size() < b.size()) && CollectionUtils.isSubCollection(a,b); }
/** * Returns <tt>true</tt> iff <i>a</i> is a <i>proper</i> sub-collection of <i>b</i>, * that is, iff the cardinality of <i>e</i> in <i>a</i> is less * than or equal to the cardinality of <i>e</i> in <i>b</i>, * for each element <i>e</i> in <i>a</i>, and there is at least one * element <i>f</i> such that the cardinality of <i>f</i> in <i>b</i> * is strictly greater than the cardinality of <i>f</i> in <i>a</i>. * <p> * The implementation assumes * <ul> * <li><code>a.size()</code> and <code>b.size()</code> represent the * total cardinality of <i>a</i> and <i>b</i>, resp. </li> * <li><code>a.size() < Integer.MAXVALUE</code></li> * </ul> * * @param a the first (sub?) collection, must not be null * @param b the second (super?) collection, must not be null * @return <code>true</code> iff <i>a</i> is a <i>proper</i> sub-collection of <i>b</i> * @see #isSubCollection * @see Collection#containsAll */ public static boolean isProperSubCollection(final Collection a, final Collection b) { return (a.size() < b.size()) && CollectionUtils.isSubCollection(a,b); }
@Override public ValidationResult validate(ConfigKey key, String value) { Collection<String> validValues = key.getValidValues(); boolean isValid = false; if (validValues.isEmpty() || value.equals("")) { isValid = true; } else { isValid = CollectionUtils.isSubCollection(Arrays.asList(value.split(",")), validValues); } return new ValidationResult(isValid); }
boolean isSubset(Object sub, Object sup) { if (null == sub || null == sup) { return false; } Collection supcollection = getCollection(sup); if (null == supcollection) { return false; } Collection subcollection = getCollection(sub); if (null == subcollection) { return false; } return CollectionUtils.isSubCollection(subcollection, supcollection); }