Example usage for org.apache.commons.collections15 ExtendedCollectionUtils size

List of usage examples for org.apache.commons.collections15 ExtendedCollectionUtils size

Introduction

In this page you can find the example usage for org.apache.commons.collections15 ExtendedCollectionUtils size.

Prototype

public static final int size(Collection<?> c) 

Source Link

Usage

From source file:net.community.chest.gitcloud.facade.AbstractContextInitializer.java

@Override
public void initialize(ConfigurableApplicationContext applicationContext) {
    ConfigurableEnvironment environment = applicationContext.getEnvironment();
    MutablePropertySources propSources = environment.getPropertySources();
    ExtendedPlaceholderResolver sourcesResolver = ExtendedPlaceholderResolverUtils
            .toPlaceholderResolver(propSources);
    File appBase = resolveApplicationBase(propSources, sourcesResolver);
    File configFile = getApplicationConfigFile(appBase, sourcesResolver);
    Collection<String> activeProfiles = resolveActiveProfiles(sourcesResolver);
    if (ExtendedCollectionUtils.size(activeProfiles) > 0) {
        environment.setActiveProfiles(activeProfiles.toArray(new String[activeProfiles.size()]));
    }/*from  w  w w  .j  av  a  2  s  .c  o  m*/

    try {
        ensureFoldersExistence(appBase, configFile, sourcesResolver);
    } catch (IOException e) {
        logger.error("ensureFoldersExistence(" + ExtendedFileUtils.toString(appBase) + ")" + " "
                + e.getClass().getSimpleName() + ": " + e.getMessage());
    }

    if (logger.isDebugEnabled()) {
        showArtifactsVersions();
    }
}

From source file:org.springframework.jdbc.repo.impl.jdbc.RawPropertiesRepoImplTest.java

@Test
public void testListEntities() {
    Set<String> expected = new TreeSet<String>();
    for (int index = 0; index < Byte.SIZE; index++) {
        TestEntry e = new TestEntry();
        repo.setProperties(e, new Transformer<TestEntry, Map<String, ?>>() {
            @Override// ww w.j  a  va 2  s. co m
            public Map<String, ?> transform(TestEntry input) {
                return Collections.<String, Serializable>singletonMap(PROP_NAME, Double.valueOf(Math.random()));
            }
        });
        expected.add(e.getId());
    }

    List<String> idsList = repo.listEntities();
    assertEquals("Mismatched entities list count", expected.size(), ExtendedCollectionUtils.size(idsList));

    Set<String> actual = new TreeSet<>(idsList);
    assertEquals("Mismatched unique entities count", idsList.size(), actual.size());

    if (!CollectionUtils.isEqualCollection(expected, actual)) {
        fail("Mismatched ID set: expected=" + expected + ", actual=" + actual);
    }
}

From source file:org.springframework.jdbc.repo.impl.jdbc.RawPropertiesRepoImplTest.java

@Test
public void testFindEntitiesByPropertyValue() {
    final String BASE_ID = "testFindEntitiesByPropertyValue";
    Map<String, Serializable> props = createEntityProperties(BASE_ID);
    List<String> expected = new ArrayList<>();
    for (int index = 0; index < Byte.SIZE; index++) {
        String id = BASE_ID + index;
        repo.setProperties(id, props);/*from   w ww .  j av a 2 s  . c o m*/
        expected.add(id);
    }

    for (Map.Entry<String, Serializable> pe : props.entrySet()) {
        String propName = pe.getKey();
        Serializable propValue = pe.getValue();
        List<String> actual = repo.findEntities(propName, propValue);
        if (!CollectionUtils.isEqualCollection(expected, actual)) {
            fail("Mismatched results for " + propName + "=" + propValue + ": expected=" + expected + ", actual="
                    + actual);
        }

        // change the type so we know it won't matcj
        if (propValue instanceof String) {
            propValue = Integer.valueOf(propValue.hashCode());
        } else {
            propValue = propValue.toString();
        }

        actual = repo.findEntities(propName, propValue);
        if (ExtendedCollectionUtils.size(actual) > 0) {
            fail("Unexpected results for " + propName + "=" + propValue + ": " + actual);
        }
    }
}

From source file:org.springframework.jdbc.repo.impl.jdbc.RawPropertiesRepoImplTest.java

@Test
public void testListMatchingIdentifiers() {
    final String COMMON_PART = "testListMatchingIdentifiers";
    // NOTE: we chose a separator that has SQL meaning on purpose
    final String COMMON_PREFIX = getClass().getSimpleName() + "#" + COMMON_PART + "%";
    Map<String, Serializable> props = createEntityProperties(COMMON_PART);
    List<String> expected = new ArrayList<String>();
    for (int index = 0; index < Byte.SIZE; index++) {
        String id = COMMON_PREFIX + index;
        repo.setProperties(id, props);/*  w  w w  . ja va 2 s.  c  o m*/
        expected.add(id);
    }

    // create some extra values
    for (int index = 0; index < Byte.SIZE; index++) {
        repo.setProperties(String.valueOf(Math.random()), props);
    }

    List<String> actual = repo.listMatchingIdentifiers("*" + COMMON_PART + "*");
    if (!CollectionUtils.isEqualCollection(expected, actual)) {
        fail("Mismatched common part wildcard results: expected=" + expected + ", actual=" + actual);
    }

    actual = repo.listMatchingIdentifiers(COMMON_PREFIX + "*");
    if (!CollectionUtils.isEqualCollection(expected, actual)) {
        fail("Mismatched common prefix wildcard results: expected=" + expected + ", actual=" + actual);
    }

    for (String id : expected) {
        actual = repo.listMatchingIdentifiers(id);
        assertEquals(id + ": Mismatched results count", 1, ExtendedCollectionUtils.size(actual));
        assertEquals("Mismatched matched identifiers", id, actual.get(0));
    }
}

From source file:org.springframework.validation.SimpleErrors.java

@Override
public void addAllErrors(Errors errors) {
    Assert.notNull(errors, "No errors to add");
    if (ExtendedStringUtils.safeCompare(getObjectName(), errors.getObjectName()) != 0) {
        throw new IllegalArgumentException("addErrors(" + getObjectName()
                + ") mismatched argument object name: " + errors.getObjectName());
    }//from  ww w. j  ava  2 s  . c  om

    Collection<? extends ObjectError> glbl = errors.getGlobalErrors();
    if (ExtendedCollectionUtils.size(glbl) > 0) {
        globalErrors.addAll(glbl);
    }

    Collection<? extends FieldError> flds = errors.getFieldErrors();
    if (ExtendedCollectionUtils.size(flds) > 0) {
        fieldErrors.addAll(flds);
    }
}

From source file:org.springframework.validation.SimpleErrors.java

@Override
public int getGlobalErrorCount() {
    return ExtendedCollectionUtils.size(getGlobalErrors());
}

From source file:org.springframework.validation.SimpleErrors.java

@Override
public int getFieldErrorCount() {
    return ExtendedCollectionUtils.size(getFieldErrors());
}