Example usage for java.util SortedSet isEmpty

List of usage examples for java.util SortedSet isEmpty

Introduction

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

Prototype

boolean isEmpty();

Source Link

Document

Returns true if this set contains no elements.

Usage

From source file:au.edu.uq.cmm.paul.grabber.Analyser.java

private void determineFolderRange(SortedSet<DatasetMetadata> inFolder) {
    if (inFolder.isEmpty()) {
        fStart = null;//from  w w  w.j av a  2 s  .  c o m
        fEnd = null;
    } else {
        Iterator<DatasetMetadata> it = inFolder.iterator();
        DatasetMetadata ds = it.next();
        fStart = fEnd = ds.getLastFileTimestamp();
        while (it.hasNext()) {
            ds = it.next();
            Date ts = ds.getLastFileTimestamp();
            if (ts.getTime() < fStart.getTime()) {
                fStart = ts;
            } else if (ts.getTime() > fEnd.getTime()) {
                fEnd = ts;
            }
        }
    }
}

From source file:gov.nih.nci.firebird.service.registration.ProfileContentPdfHelper.java

void addDegrees(int index) throws DocumentException {
    PdfPTable table = pdfGenerator.createTable(THREE_COLUMNS);
    addDegreeHeadings(table, index, DEGREES_TITLE_KEY);
    SortedSet<AbstractCredential<?>> credentials = getProfile().getCurrentCredentials(CredentialType.DEGREE);
    if (credentials.isEmpty()) {
        pdfGenerator.addCellAndCompleteRow(table, pdfGenerator.getValueNone());
    } else {/* w ww.j av a 2  s  .  c  o  m*/
        addDegrees(table, credentials);
    }
    pdfGenerator.getDocument().add(table);
}

From source file:gov.nih.nci.firebird.service.registration.ProfileContentPdfHelper.java

void addSpecialties(int index) throws DocumentException {
    PdfPTable table = pdfGenerator.createTable(FIVE_COLUMNS);
    addSpecialtyHeadings(table, index, SPECIALTIES_TITLE_KEY);
    SortedSet<AbstractCredential<?>> credentials = getProfile().getCurrentCredentials(CredentialType.SPECIALTY);
    if (credentials.isEmpty()) {
        pdfGenerator.addCellAndCompleteRow(table, pdfGenerator.getValueNone());
    } else {/*from w  ww. j av a 2 s .  com*/
        addSpecialties(table, credentials);
    }
    pdfGenerator.getDocument().add(table);
}

From source file:com.smhdemo.common.datasource.generate.factory.init.bean.BeanForInterfaceFactory.java

@SuppressWarnings({ "rawtypes", "unchecked" })
@Override//  w ww . j  a  v  a2  s.  c  o  m
public String getBeanName(Map interfaceToBeanMappings, Class itfClass) {
    if (interfaceToBeanMappings == null) {
        return null;
    }

    try {
        SortedSet interfaces = new TreeSet(itfComparator);

        for (Iterator it = interfaceToBeanMappings.keySet().iterator(); it.hasNext();) {
            String itfName = (String) it.next();
            Class itf = Class.forName(itfName, true, Thread.currentThread().getContextClassLoader());
            if (itf.isAssignableFrom(itfClass)) {
                interfaces.add(itf);
            }
        }

        if (!interfaces.isEmpty()) {
            Class itf = (Class) interfaces.iterator().next();
            return (String) interfaceToBeanMappings.get(itf.getName());
        }
        return null;
    } catch (ClassNotFoundException e) {
        logger.error("ClassNotFoundException", e);
        throw new BaseRuntimeExceptionWrapper(e);
    }
}

From source file:org.sfs.nodes.compute.container.GetContainer.java

@Override
public void handle(final SfsRequest httpServerRequest) {

    VertxContext<Server> vertxContext = httpServerRequest.vertxContext();
    aVoid().flatMap(new Authenticate(httpServerRequest))
            .flatMap(new ValidateActionAuthenticated(httpServerRequest))
            .map(aVoid -> fromSfsRequest(httpServerRequest)).map(new ValidateContainerPath())
            .flatMap(new LoadAccountAndContainer(vertxContext))
            .flatMap(new ValidateActionContainerListObjects(httpServerRequest)).flatMap(persistentContainer -> {

                HttpServerResponse httpServerResponse = httpServerRequest.response();

                MultiMap queryParams = httpServerRequest.params();
                MultiMap headerParams = httpServerRequest.headers();

                String format = queryParams.get(FORMAT);
                String accept = headerParams.get(ACCEPT);

                MediaType parsedAccept = null;

                if (equalsIgnoreCase("xml", format)) {
                    parsedAccept = APPLICATION_XML_UTF_8;
                } else if (equalsIgnoreCase("json", format)) {
                    parsedAccept = JSON_UTF_8;
                }// w  w w. j a v a 2  s .c o  m

                if (parsedAccept == null) {
                    if (!isNullOrEmpty(accept)) {
                        parsedAccept = parse(accept);
                    }
                }

                if (parsedAccept == null || (!PLAIN_TEXT_UTF_8.is(parsedAccept)
                        && !APPLICATION_XML_UTF_8.is(parsedAccept) && !JSON_UTF_8.equals(parsedAccept))) {
                    parsedAccept = PLAIN_TEXT_UTF_8;
                }

                Observable<Optional<ContainerStats>> oContainerStats;
                boolean hasPrefix = !Strings.isNullOrEmpty(queryParams.get(SfsHttpQueryParams.PREFIX));
                if (hasPrefix) {
                    oContainerStats = just(persistentContainer)
                            .flatMap(new LoadContainerStats(httpServerRequest.vertxContext()))
                            .map(Optional::of);
                } else {
                    oContainerStats = Defer.just(Optional.<ContainerStats>absent());
                }

                Observable<ObjectList> oObjectListing = just(persistentContainer)
                        .flatMap(new ListObjects(httpServerRequest));

                MediaType finalParsedAccept = parsedAccept;
                return combineSinglesDelayError(oContainerStats, oObjectListing,
                        (containerStats, objectList) -> {

                            if (containerStats.isPresent()) {

                                Metadata metadata = persistentContainer.getMetadata();

                                for (String key : metadata.keySet()) {
                                    SortedSet<String> values = metadata.get(key);
                                    if (values != null && !values.isEmpty()) {
                                        httpServerResponse.putHeader(
                                                format("%s%s", X_ADD_CONTAINER_META_PREFIX, key), values);
                                    }
                                }

                                httpServerResponse.putHeader(X_CONTAINER_OBJECT_COUNT,
                                        valueOf(containerStats.get().getObjectCount()));
                                httpServerResponse.putHeader(X_CONTAINER_BYTES_USED,
                                        BigDecimal.valueOf(containerStats.get().getBytesUsed())
                                                .setScale(0, ROUND_HALF_UP).toString());
                            }

                            BufferOutputStream bufferOutputStream = new BufferOutputStream();

                            if (JSON_UTF_8.is(finalParsedAccept)) {

                                try {
                                    JsonFactory jsonFactory = vertxContext.verticle().jsonFactory();
                                    JsonGenerator jg = jsonFactory.createGenerator(bufferOutputStream, UTF8);
                                    jg.writeStartArray();

                                    for (ListedObject listedObject : ordered(objectList.getObjects())) {

                                        jg.writeStartObject();
                                        jg.writeStringField("hash",
                                                base16().lowerCase().encode(listedObject.getEtag()));
                                        jg.writeStringField("last_modified",
                                                toDateTimeString(listedObject.getLastModified()));
                                        jg.writeNumberField("bytes", listedObject.getLength());
                                        jg.writeStringField("content_type", listedObject.getContentType());
                                        jg.writeStringField("name", listedObject.getName());
                                        jg.writeEndObject();
                                    }

                                    jg.writeEndArray();
                                    jg.close();
                                } catch (IOException e) {
                                    throw new RuntimeException(e);
                                }

                            } else if (APPLICATION_XML_UTF_8.is(finalParsedAccept)) {

                                String charset = UTF_8.toString();
                                XMLStreamWriter writer = null;
                                try {
                                    writer = newFactory().createXMLStreamWriter(bufferOutputStream, charset);

                                    writer.writeStartDocument(charset, "1.0");

                                    writer.writeStartElement("container");

                                    writer.writeAttribute("name",
                                            fromPaths(persistentContainer.getId()).containerName().get());

                                    for (ListedObject listedObject : ordered(objectList.getObjects())) {

                                        writer.writeStartElement("object");

                                        writer.writeStartElement("name");
                                        writer.writeCharacters(listedObject.getName());
                                        writer.writeEndElement();

                                        writer.writeStartElement("hash");
                                        writer.writeCharacters(
                                                base16().lowerCase().encode(listedObject.getEtag()));
                                        writer.writeEndElement();

                                        writer.writeStartElement("bytes");
                                        writer.writeCharacters(valueOf(listedObject.getLength()));
                                        writer.writeEndElement();

                                        writer.writeStartElement("content_type");
                                        writer.writeCharacters(listedObject.getContentType());
                                        writer.writeEndElement();

                                        writer.writeStartElement("last_modified");
                                        writer.writeCharacters(
                                                toDateTimeString(listedObject.getLastModified()));
                                        writer.writeEndElement();

                                        writer.writeEndElement();
                                    }

                                    writer.writeEndElement();

                                    writer.writeEndDocument();

                                } catch (XMLStreamException e) {
                                    throw new RuntimeException(e);
                                } finally {
                                    try {
                                        if (writer != null) {
                                            writer.close();
                                        }
                                    } catch (XMLStreamException e) {
                                        LOGGER.warn(e.getLocalizedMessage(), e);
                                    }
                                }

                            } else {
                                String charset = UTF_8.toString();
                                try (OutputStreamWriter outputStreamWriter = new OutputStreamWriter(
                                        bufferOutputStream, charset)) {
                                    for (ListedObject listedObject : ordered(objectList.getObjects())) {
                                        outputStreamWriter.write(listedObject.getName());
                                        outputStreamWriter.write("\n");
                                    }
                                } catch (IOException e) {
                                    throw new RuntimeException(e);
                                }
                            }
                            objectList.clear();
                            return bufferOutputStream;
                        }).flatMap(bufferOutputStream -> {
                            Buffer buffer = bufferOutputStream.toBuffer();
                            httpServerResponse.putHeader(HttpHeaders.CONTENT_TYPE, finalParsedAccept.toString())
                                    .putHeader(HttpHeaders.CONTENT_LENGTH, String.valueOf(buffer.length()));
                            return AsyncIO.append(buffer, httpServerRequest.response());
                        });
            }).single().subscribe(new ConnectionCloseTerminus<Void>(httpServerRequest) {
                @Override
                public void onNext(Void aVoid) {

                }
            }

    );

}

From source file:org.tonguetied.usermanagement.User.java

/**
 * @param userRights the authorized permissions to set
 *///from   www . jav a  2  s.  c o m
public void setUserRights(SortedSet<UserRight> userRights) {
    this.userRights = userRights;
    if (userRights != null && !userRights.isEmpty()) {
        Set<GrantedAuthority> authorities = new HashSet<GrantedAuthority>();
        GrantedAuthority authority;
        for (UserRight userRight : getUserRights()) {
            authority = new GrantedAuthorityImpl(userRight.getPermission().name());
            authorities.add(authority);
        }

        this.setAuthorities(authorities.toArray(new GrantedAuthority[authorities.size()]));
    }
}

From source file:net.sourceforge.fenixedu.domain.alumni.AlumniReportFile.java

public PhysicalAddress getLastPersonalAddress(final Person person) {
    if (person.getStudent().getAlumni() != null) {
        return person.getStudent().getAlumni().getLastPersonalAddress();
    }// w w w  .  j a  va  2 s.co  m

    SortedSet<PhysicalAddress> addressSet = new TreeSet<PhysicalAddress>(DomainObjectUtil.COMPARATOR_BY_ID);
    addressSet.addAll(person.getPhysicalAddresses());
    return !addressSet.isEmpty() && addressSet.last() != null ? addressSet.last() : null;
}

From source file:gov.nih.nci.firebird.service.registration.ProfileContentPdfHelper.java

void addLicenses(int index) throws DocumentException {
    PdfPTable table = pdfGenerator.createTable(FOUR_COLUMNS);
    addLicenseHeadings(table, index, LICENSES_TITLE_KEY);
    SortedSet<AbstractCredential<?>> credentials = getProfile()
            .getCurrentCredentials(CredentialType.MEDICAL_LICENSE);
    if (credentials.isEmpty()) {
        pdfGenerator.addCellAndCompleteRow(table, pdfGenerator.getValueNone());
    } else {/*from  w w  w. j a  v a 2 s  .c  om*/
        addLicenses(table, credentials);
    }
    pdfGenerator.getDocument().add(table);
}

From source file:com.jaspersoft.jasperserver.api.common.service.impl.BeanForInterfaceFactoryImpl.java

public String getBeanName(Map interfaceToBeanMappings, Class itfClass) {
    if (interfaceToBeanMappings == null) {
        return null;
    }//from  ww w  .j a va2  s. com

    //TODO cache
    try {
        SortedSet interfaces = new TreeSet(itfComparator);

        for (Iterator it = interfaceToBeanMappings.keySet().iterator(); it.hasNext();) {
            String itfName = (String) it.next();
            Class itf = Class.forName(itfName, true, Thread.currentThread().getContextClassLoader());
            if (itf.isAssignableFrom(itfClass)) {
                interfaces.add(itf);
            }
        }

        if (!interfaces.isEmpty()) {
            Class itf = (Class) interfaces.iterator().next();
            return (String) interfaceToBeanMappings.get(itf.getName());
        }
        return null;
    } catch (ClassNotFoundException e) {
        log.error(e, e);
        throw new JSExceptionWrapper(e);
    }
}

From source file:org.apache.kylin.common.KylinConfigBase.java

private static String getFileName(String homePath, Pattern pattern) {
    File home = new File(homePath);
    SortedSet<String> files = Sets.newTreeSet();
    if (home.exists() && home.isDirectory()) {
        File[] listFiles = home.listFiles();
        if (listFiles != null) {
            for (File file : listFiles) {
                final Matcher matcher = pattern.matcher(file.getName());
                if (matcher.matches()) {
                    files.add(file.getAbsolutePath());
                }//from   ww  w .  j  av a  2 s  .c  o m
            }
        }
    }
    if (files.isEmpty()) {
        throw new RuntimeException("cannot find " + pattern.toString() + " in " + homePath);
    } else {
        return files.last();
    }
}