Code Monkey home page Code Monkey logo

utils's People

Contributors

dependabot[bot] avatar rkumsher avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

utils's Issues

Add IterableUtils.containsAll()

Similar to List.containsAll

/**
 * Returns whether or not the given {@link Iterable} contains all the given elements to check for.
 *
 * <pre>
 *   IterableUtils.containsAll(Collections.emptyList(), Collections.emptyList()) = true;
 *   IterableUtils.containsAll(Lists.newArrayList("a"), Lists.newArrayList("a")) = true;
 *   IterableUtils.containsAll(Lists.newArrayList("a"), Lists.newArrayList("b")) = false;
 *   IterableUtils.containsAll(Lists.newArrayList("a", "b"), Lists.newArrayList("a", "b", "a", "b")) = true;
 * </pre>
 *
 * @param iterableToCheck {@link Iterable} to to check
 * @param elementsToCheckFor elements to check for
 * @param <T> the type of elements in the given iterables
 * @return whether or not the given {@link Iterable} contains all the given elements to check for.
 */
public static <T> boolean containsAll(Iterable<T> iterableToCheck, Iterable<T> elementsToCheckFor) {
  ...
}

Add randomSetFrom methods to RandomCollectionUtils

I attended to include this in v1.0 but couldn't decide how it should behave.

For example:

randomSetFrom(() -> "a", 3);
randomSetFrom(Sets.newHashSet("a", "b", "c"), 3);

Neither of the above could create a set with 3 elements

I suspect the behavior will have to be something like:

/**
 * Returns a set filled randomly from the given elements. This will randomly put <code>
 * attemptedSize</code> elements into the set, if any are equal then the returned set will contain
 * less than <code>attemptedSize</code> elements.
 *
 * @param elements elements to randomly fill list from
 * @param attemptedSize attempted size of the random set to return
 * @param <T> the type of elements in the given iterable
 * @return set filled randomly from the given elements
 * @throws IllegalArgumentException if the elements to fill set from is empty or if the size is
 *     negative
 */
public static <T> Set<T> randomSetFrom(Iterable<T> elements, int attemptedSize) {
  ...
}

Move isLeapYear to DateUtils

Currently, isLeapYear is in RandomDateUtils and is package-private. Move to DateUtils and make public.

Also relax the type to accept TemporalAccessor instead of just MonthDay

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.