Example usage for java.util Collection isEmpty

List of usage examples for java.util Collection isEmpty

Introduction

In this page you can find the example usage for java.util Collection isEmpty.

Prototype

boolean isEmpty();

Source Link

Document

Returns true if this collection contains no elements.

Usage

From source file:edu.mayo.informatics.lexgrid.convert.directConversions.protegeOwl.CreateUtils.java

public static AssociationQualification createAssociationQualification(RDFProperty rdfProp,
        SupportedMappings lgSupportedMappings_) {
    String brText = rdfProp.getBrowserText();
    Collection labels = rdfProp.getLabels();
    AssociationQualification lgQual = createAssociationQualification(brText, rdfProp.getURI(),
            labels.isEmpty() ? brText : labels.iterator().next().toString(), lgSupportedMappings_);
    return lgQual;
}

From source file:de.stefanbohne.ubiqlip.messaging.MIMEParse.java

/**
 * Takes a list of supported mime-types and finds the best match for all the
 * media-ranges listed in header. The value of header must be a string that
 * conforms to the format of the HTTP Accept: header. The value of
 * 'supported' is a list of mime-types.//from  ww w .java2s  .co m
 *
 * MimeParse.bestMatch(Arrays.asList(new String[]{"application/xbel+xml",
 * "text/xml"}), "text/*;q=0.5,*; q=0.1") 'text/xml'
 *
 * @param supported
 * @param header
 * @return
 */
public static String bestMatch(Collection<String> supported, String header) {
    if (supported.isEmpty())
        return "";
    List<ParseResults> parseResults = new LinkedList<ParseResults>();
    List<FitnessAndQuality> weightedMatches = new LinkedList<FitnessAndQuality>();
    for (String r : StringUtils.split(header, ','))
        parseResults.add(parseMediaRange(r));

    for (String s : supported) {
        FitnessAndQuality fitnessAndQuality = fitnessAndQualityParsed(s, parseResults);
        fitnessAndQuality.mimeType = s;
        weightedMatches.add(fitnessAndQuality);
    }
    Collections.sort(weightedMatches);

    FitnessAndQuality lastOne = weightedMatches.get(weightedMatches.size() - 1);
    return NumberUtils.compare(lastOne.quality, 0) != 0 ? lastOne.mimeType : "";
}

From source file:com.fjn.helper.common.util.StringUtil.java

/**
 * Listsplit// ww w .  j  a v a2s . co m
 * @param list
 * @param split
 * @return
 */
public static String collectionToString(Collection list, String split) {
    if (isEmpty(split)) {
        split = ", ";
    }
    StringBuilder buf = new StringBuilder();
    if (list != null && !list.isEmpty()) {
        Iterator iter = list.iterator();
        if (iter.hasNext()) {
            buf.append(iter.next());
        }
        while (iter.hasNext()) {
            buf.append(split).append(iter.next());
        }
    }
    return buf.toString();
}

From source file:com.wdhis.util.CollectionsUtil.java

/**
 * ?./*from w  ww. j a  v  a  2 s  .  co m*/
 */
public static boolean isEmpty(Collection collection) {
    System.out.println("3333333333333333333333");
    return (collection == null) || collection.isEmpty();
}

From source file:net.sourceforge.fenixedu.domain.organizationalStructure.ExternalContract.java

public static List<ExternalContract> readByIDs(Collection<String> accountabilityIDs) {
    List<ExternalContract> externalPersons = new ArrayList<ExternalContract>();
    if (accountabilityIDs == null || accountabilityIDs.isEmpty()) {
        return externalPersons;
    }/*from  w w  w . ja  v  a  2 s  . co m*/
    for (Accountability accountability : Bennu.getInstance().getAccountabilitysSet()) {
        if (accountability instanceof ExternalContract) {
            ExternalContract externalPerson = (ExternalContract) accountability;
            if (accountabilityIDs.contains(externalPerson.getExternalId())) {
                externalPersons.add(externalPerson);
            }
        }
    }
    return externalPersons;
}

From source file:com.firstproj.testtwo.web.Test.java

public static void testFlickr() throws Exception {
    Flickr f = new Flickr("df1e5e194de94bb405b2ce898db83b90", "ed6088a596f20afd", new REST());
    Auth auth = new Auth();
    User user = new User();
    user.setId("jwlee208");
    auth.setUser(user);//w  w  w.  ja  v a2 s .c  o m
    f.setAuth(auth);

    GroupsInterface groups = f.getGroupsInterface();

    // search group
    Collection<Group> searchedGroups = groups.search("jwlee208", 10, 10);

    if (!searchedGroups.isEmpty()) {
        System.out.println("SearchGroups > ");
        for (Group group : searchedGroups) {
            System.out.println(group.getName());
        }
    }

    System.out.println(groups.search("[jQuery] window.onload ready()", 1, 1));

    PhotosInterface photos = f.getPhotosInterface();
    SearchParameters params = new SearchParameters();
    params.setUserId("jwlee208");
    params.setSafeSearch(Flickr.SAFETYLEVEL_SAFE);
    //        params.setText("jquery");

    PhotoList<Photo> photoList = photos.search(params, 100, 1);
    Collection<Photocount> photoCount = photos.getCounts(null, null);
    System.out.println(photoCount.size());
    //                photos.getContactsPhotos(10, true, true, true);

    if (!photoList.isEmpty()) {
        for (Photo photo : photoList) {
            System.out.println("photo.getTitle() : " + photo.getTitle() + "\nphoto.getLargeUrl() : "
                    + photo.getLargeUrl() + "\nphoto.getLicense() : " + photo.getLicense()
                    + "\nphoto.getUrls() : " + photo.getUrls() + "\nphoto.getTags() : " + photo.getTags()
                    + "\n photo.getPhotoUrl() : " + photo.getPhotoUrl() + "\nphoto.getPermissions() : "
                    + photo.getPermissions() + "\nphoto.getThumbnailUrl() : " + photo.getThumbnailUrl());
            System.out.println("\n----------------------------------");
        }
    }

    TestInterface testInterface = f.getTestInterface();
    Collection results = testInterface.echo(Collections.EMPTY_MAP);

    System.out.println(results);
    List<Gallery> list = new ArrayList<Gallery>();

    System.out.println(list.size());
    if (list.size() > 0) {
        for (Gallery gallery : list) {
            System.out.println(gallery.getTitle());
        }
    }
}

From source file:com.github.pjungermann.config.types.DefaultConfigFactorySelectorTest.java

static void assertValidBean(ConfigFactorySelector selector) {
    assertTrue(selector instanceof DefaultConfigFactorySelector);
    assertNull(selector.getFactory(new File("foo.bar")));
    Collection<ConfigFactory> configFactories = getConfigFactories((DefaultConfigFactorySelector) selector);
    //noinspection ConstantConditions
    assertTrue(configFactories.isEmpty());
}

From source file:org.codehaus.groovy.grails.plugins.searchable.compass.mapping.SearchableGrailsDomainClassCompassMappingUtils.java

/**
 * Builds a CompassClassMapping for the GrailsDomainClass and property mappings
 * @param grailsDomainClass/*from w  w w  . j  a va2 s. co  m*/
 * @param searchableGrailsDomainClasses
 * @param propertyMappings
 * @return
 */
public static CompassClassMapping buildCompassClassMapping(GrailsDomainClass grailsDomainClass,
        Collection searchableGrailsDomainClasses, List propertyMappings, String alias) {
    CompassClassMapping classMapping = new CompassClassMapping();
    classMapping.setMappedClass(grailsDomainClass.getClazz());
    if (alias != null) {
        classMapping.setAlias(alias);
    }
    classMapping.setPropertyMappings(propertyMappings);
    classMapping.setRoot(SearchableGrailsDomainClassCompassMappingUtils.isRoot(grailsDomainClass,
            searchableGrailsDomainClasses));
    Collection superClasses = GrailsDomainClassUtils.getSuperClasses(grailsDomainClass,
            searchableGrailsDomainClasses);
    if (!superClasses.isEmpty()) {
        GrailsDomainClass parent = GrailsDomainClassUtils.getSuperClass(grailsDomainClass, superClasses);
        classMapping.setMappedClassSuperClass(parent.getClazz());
    }
    if (GrailsDomainClassUtils.isWithinInhertitanceHierarchy(grailsDomainClass,
            searchableGrailsDomainClasses)) {
        classMapping.addConstantMetaData("$/poly/class", new HashMap() {
            {
                put("index", "un_tokenized");
                put("excludeFromAll", Boolean.TRUE);
            }
        }, Arrays.asList(new String[] { grailsDomainClass.getClazz().getName() }));
    }
    classMapping.setPoly(
            !grailsDomainClass.getSubClasses().isEmpty() || classMapping.getMappedClassSuperClass() != null);
    return classMapping;
}

From source file:grails.plugin.searchable.internal.compass.mapping.SearchableGrailsDomainClassCompassMappingUtils.java

/**
 * Builds a CompassClassMapping for the GrailsDomainClass and property mappings
 * @param grailsDomainClass/*from  w ww  . ja v  a2 s.c o  m*/
 * @param searchableGrailsDomainClasses
 * @param propertyMappings
 * @return
 */
public static CompassClassMapping buildCompassClassMapping(GrailsDomainClass grailsDomainClass,
        Collection searchableGrailsDomainClasses, List propertyMappings) {
    CompassClassMapping classMapping = new CompassClassMapping();
    classMapping.setMappedClass(grailsDomainClass.getClazz());
    classMapping.setPropertyMappings(propertyMappings);
    if (classMapping.getRoot() == null) {
        classMapping.setRoot(Boolean.valueOf(SearchableGrailsDomainClassCompassMappingUtils
                .isRoot(grailsDomainClass, searchableGrailsDomainClasses)));
    }
    Collection superClasses = GrailsDomainClassUtils.getSuperClasses(grailsDomainClass,
            searchableGrailsDomainClasses);
    if (!superClasses.isEmpty()) {
        GrailsDomainClass parent = GrailsDomainClassUtils.getSuperClass(grailsDomainClass, superClasses);
        classMapping.setMappedClassSuperClass(parent.getClazz());
    }
    if (GrailsDomainClassUtils.isWithinInhertitanceHierarchy(grailsDomainClass,
            searchableGrailsDomainClasses)) {
        Map data = new HashMap();
        data.put("index", "not_analyzed");
        data.put("excludeFromAll", true);
        classMapping.addConstantMetaData("$/poly/class", data,
                Arrays.asList(grailsDomainClass.getClazz().getName()));
    }
    classMapping.setPoly(
            !grailsDomainClass.getSubClasses().isEmpty() || classMapping.getMappedClassSuperClass() != null);
    return classMapping;
}

From source file:alfio.util.Validator.java

private static boolean isCollectionEmpty(Collection<?> collection) {
    return collection == null || collection.isEmpty();
}