Java Collection Unique uniqueIdNotIn(String prefix, Collection exclusions)

Here you can find the source of uniqueIdNotIn(String prefix, Collection exclusions)

Description

unique Id Not In

License

Apache License

Declaration

private static String uniqueIdNotIn(String prefix, Collection<? extends String> exclusions) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.Collection;

public class Main {
    private static String uniqueIdNotIn(String prefix, Collection<? extends String> exclusions) {
        StringBuilder sb = new StringBuilder(prefix);
        for (int counter = 0;; ++counter) {
            sb.setLength(prefix.length());
            sb.append('.').append(counter);
            String candidate = sb.toString();
            if (!exclusions.contains(candidate)) {
                return candidate;
            }/*from ww  w .  j  a  va  2  s . co m*/
        }
    }
}

Related

  1. hasUniqueObject(Collection collection)
  2. hasUniqueObject(Collection collection)
  3. hasUniqueObject(Collection collection)
  4. unique(Collection c)
  5. unique(Collection c, Collection result)
  6. uniqueResult(Collection results)
  7. uniqueResult(final Collection c)