Example usage for java.util Set isEmpty

List of usage examples for java.util Set isEmpty

Introduction

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

Prototype

boolean isEmpty();

Source Link

Document

Returns true if this set contains no elements.

Usage

From source file:net.andydvorak.intellij.lessc.fs.VirtualFileLocationChange.java

public static int deleteCssFiles(@NotNull final VirtualFileEvent virtualFileEvent,
        @Nullable final LessProfile lessProfile, @NotNull final VfsLocationChangeDialog vfsLocationChangeDialog)
        throws IOException {
    final Set<VirtualFileLocationChange> changes = getChanges(lessProfile, virtualFileEvent.getFile(),
            virtualFileEvent.getFile().getParent());

    if (changes.isEmpty() || !vfsLocationChangeDialog.shouldDeleteCssFile(virtualFileEvent))
        return 0;

    for (VirtualFileLocationChange locationChange : changes) {
        locationChange.delete();/*from w  w  w. j  a v a2s. com*/
    }

    return changes.size();
}

From source file:cop.raml.utils.Utils.java

@NotNull
public static Set<String> getParams(String uri) {
    if (StringUtils.isBlank(uri))
        return Collections.emptySet();

    Set<String> names = new LinkedHashSet<>();
    Matcher matcher = URI_PARAM.matcher(uri);

    while (matcher.find())
        names.add(matcher.group(1));/* w  w  w. j  ava2 s . c  o m*/

    return names.isEmpty() ? Collections.emptySet() : names;
}

From source file:Main.java

static <E> Set<E> ungrowableSet(final Set<E> s) {
    return new Set<E>() {

        @Override/*from w  w  w  .  ja v a 2  s  .co m*/
        public int size() {
            return s.size();
        }

        @Override
        public boolean isEmpty() {
            return s.isEmpty();
        }

        @Override
        public boolean contains(Object o) {
            return s.contains(o);
        }

        @Override
        public Object[] toArray() {
            return s.toArray();
        }

        @Override
        public <T> T[] toArray(T[] a) {
            return s.toArray(a);
        }

        @Override
        public String toString() {
            return s.toString();
        }

        @Override
        public Iterator<E> iterator() {
            return s.iterator();
        }

        @Override
        public boolean equals(Object o) {
            return s.equals(o);
        }

        @Override
        public int hashCode() {
            return s.hashCode();
        }

        @Override
        public void clear() {
            s.clear();
        }

        @Override
        public boolean remove(Object o) {
            return s.remove(o);
        }

        @Override
        public boolean containsAll(Collection<?> coll) {
            return s.containsAll(coll);
        }

        @Override
        public boolean removeAll(Collection<?> coll) {
            return s.removeAll(coll);
        }

        @Override
        public boolean retainAll(Collection<?> coll) {
            return s.retainAll(coll);
        }

        @Override
        public boolean add(E o) {
            throw new UnsupportedOperationException();
        }

        @Override
        public boolean addAll(Collection<? extends E> coll) {
            throw new UnsupportedOperationException();
        }

    };

}

From source file:au.org.ala.delta.intkey.model.FormattingUtils.java

/**
 * Formats the values set for an integer character as a string. It is
 * assumed the values for the integer character have already been processed
 * such that they are in the range minimumValue - 1 to maximumValue + 1.
 * //from   w ww.j a  va 2 s  .  c  om
 * @param integerValues
 *            the values set for the integer character
 * @param minimumValue
 *            the character's minimum value
 * @param maximumValue
 *            the character's maximum value
 * @return the integer character's values formatted as a string.
 */
public static String formatIntegerValuesAsString(Set<Integer> integerValues, int minimumValue,
        int maximumValue) {
    Set<Integer> valuesCopy = new HashSet<Integer>(integerValues);

    List<String> stringParts = new ArrayList<String>();

    if (integerValues.contains(minimumValue - 1)) {
        stringParts.add(Integer.toString(minimumValue - 1));
    }

    valuesCopy.remove(minimumValue - 1);
    valuesCopy.remove(maximumValue + 1);

    if (!valuesCopy.isEmpty()) {
        List<Integer> valuesCopyAsList = new ArrayList<Integer>(valuesCopy);
        Collections.sort(valuesCopyAsList);
        stringParts.add(Utils.formatIntegersAsListOfRanges(valuesCopyAsList, "/", "-"));
    }

    if (integerValues.contains(maximumValue + 1)) {
        stringParts.add(Integer.toString(maximumValue + 1));
    }

    return StringUtils.join(stringParts, "/");
}

From source file:com.hp.autonomy.aci.content.database.Databases.java

/**
 * Parses a {@code String} of database names in the format used in a <tt>query</tt> or <tt>getcontent</tt> action.
 * This includes parsing the output of {@link #toString()}. An empty string will be treated as equivalent to
 * <tt>*</tt>, even though technically there is a slight difference when working with internal databases.
 *
 * @param databases The string representation to parse
 * @return A {@code Databases} object//w w  w.java  2 s  . c  o m
 */
public static Databases parse(final String databases) {
    Validate.notNull(databases, "Databases must not be null");

    if (SPACES.matcher(databases).matches()) {
        return Databases.ALL;
    }

    final Set<String> databasesSet = new LinkedHashSet<String>(Arrays.asList(SEPARATORS.split(databases)));
    databasesSet.remove("");

    if (databasesSet.isEmpty()) {
        return new Databases();
    }

    if ("*".equals(databasesSet.iterator().next())) {
        return ALL;
    }

    databasesSet.remove("*");
    databasesSet.remove(MATCH_NOTHING);

    return new Databases(databasesSet);
}

From source file:com.tesora.dve.tools.aitemplatebuilder.PrivateRange.java

private static PrivateRange getValidRange(final PrivateRange range) {
    final Set<TableColumn> rangeColumns = range.getRangeColumnsFor(range.getTable());

    if (!rangeColumns.isEmpty()) {
        if ((!range.isSafeMode() || (range.isSafeMode() && AiTemplateBuilder.hasAutoIncrement(rangeColumns)))
                && AiTemplateBuilder.hasRangeCompatible(rangeColumns)) {
            return range;
        }//from   ww w  . java  2 s .c  o  m
    }

    return null;
}

From source file:com.tech.utils.CustomCollectionUtil.java

/**
 * Generic Method to convert set to list of objects
 * /*from w  w w .java  2s  .c o m*/
 * @param set
 * @return
 */
public static List<?> convertSetToList(Set<?> set) {
    if (set != null && !set.isEmpty()) {
        List<Object> list = new ArrayList<Object>();
        for (Object obj : set) {
            list.add(obj);
        }
        return list;
    }
    return null;
}

From source file:hudson.plugins.trackplus.Updater.java

static boolean perform(AbstractBuild<?, ?> build, BuildListener listener)
        throws InterruptedException, IOException {
    PrintStream logger = listener.getLogger();
    List<TrackplusIssue> issues = null;
    AbstractProject p = build.getProject();
    try {//from w  w  w.ja va2s. co m
        TrackplusSite site = TrackplusSite.get(build.getProject());
        if (site == null) {
            logger.println(Messages.Updater_NoTrackplusSite());
            build.setResult(Result.FAILURE);
            return true;
        }

        String rootUrl = Hudson.getInstance().getRootUrl();

        if (rootUrl == null) {
            logger.println(Messages.Updater_NoHudsonUrl());
            build.setResult(Result.FAILURE);
            return true;
        }

        Set<Integer> ids = findIssueIdsRecursive(build, site.getIssuePrefix(), listener);

        if (ids.isEmpty()) {
            if (debug) {
                logger.println("No Track+ issues found.");
            }
            return true; // nothing found here.
        }

        TrackplusSession session = null;
        try {
            session = site.createSession();
        } catch (/*Service*/Exception e) {
            listener.getLogger().println(Messages.Updater_FailedToConnect());
            e.printStackTrace(listener.getLogger());
        }
        if (session == null) {
            logger.println(Messages.Updater_NoRemoteAccess());
            build.setResult(Result.FAILURE);
            return true;
        }

        boolean doUpdate = false;
        if (site.updateTrackplusIssueForAllStatus) {
            doUpdate = true;
        } else {
            doUpdate = build.getResult().isBetterOrEqualTo(Result.UNSTABLE);
        }

        issues = getTrackplusIssues(ids, session, logger);

        build.getActions().add(new TrackplusBuildAction(build, issues));

        if (doUpdate) {
            submitComments(build, logger, rootUrl, issues, session, site.recordScmChanges);
        } else {
            // this build didn't work, so carry forward the issues to the next build
            build.addAction(new TrackplusCarryOverAction(issues));
        }
    } catch (Exception e) {
        logger.println("Error updating trackplus issues. Saving issues for next build.\n" + e);
        if (issues != null && !issues.isEmpty()) {
            // updating issues failed, so carry forward issues to the next build
            build.addAction(new TrackplusCarryOverAction(issues));
        }
    }

    return true;
}

From source file:modula.parser.io.ModelUpdater.java

/**
 * transition/* w ww .ja  v a 2s .co m*/
 */
private static void updateTransition(final SimpleTransition transition,
        final Map<String, TransitionTarget> targets) throws ModelException {
    String next = transition.getNext();
    if (next == null) { // stay transition
        return;
    }
    Set<TransitionTarget> tts = transition.getTargets();
    if (tts.isEmpty()) {
        // 'next' is a space separated list of transition target IDs
        StringTokenizer ids = new StringTokenizer(next);
        while (ids.hasMoreTokens()) {
            String id = ids.nextToken();
            TransitionTarget tt = targets.get(id);
            if (tt == null) {
                logAndThrowModelError(ERR_TARGET_NOT_FOUND, new Object[] { id });
            }
            tts.add(tt);
        }
        if (tts.size() > 1) {
            boolean legal = verifyTransitionTargets(tts);
            if (!legal) {
                logAndThrowModelError(ERR_ILLEGAL_TARGETS, new Object[] { next });
            }
        }
    }
}

From source file:com.tech.utils.CustomCollectionUtil.java

/**
 * Check whether List is empty.//ww  w.  j a  v a  2s  .  c om
 * 
 * @param set
 *            - Set to be checked.
 * @return whether empty or not.
 */
public static boolean isSetEmpty(final Set<? extends Object> set) {
    if (set == null || set.isEmpty()) {
        return true;
    }
    return false;
}