Skip to content

SirWellington/alchemy-collections

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Alchemy Collections

"Collect Yo'Self"

Build Status Maven Central Version

Purpose

Part of the Alchemy Collection, Alchemy Collections contains Algorithms and Operations you would intuitively expect to perform on a java Collection.

Because odds are, if you want to do it, someone else does too,

Download

To use, simply add the following maven dependency.

Release

<dependency>
	<groupId>tech.sirwellington.alchemy</groupId>
	<artifactId>alchemy-collections</artifactId>
	<version>2.0</version>
</dependency>

Snapshot

First add the Snapshot Repository

<repository>
	<id>ossrh</id>
    <url>https://oss.sonatype.org/content/repositories/snapshots</url>
</repository>
<dependency>
	<groupId>tech.sirwellington.alchemy</groupId>
	<artifactId>alchemy-collections</artifactId>
	<version>2.1-SNAPSHOT</version>
</dependency>

API

Lists

sir.wellington.alchemy.collections.lists.Lists

Create

List<User> users = Lists.create();
List<User> defensiveCopy = Lists.immutableCopyOf(users);

Combine

List<People> clique = Lists.combine(family, coworkers, enemies, neighbors);

Any String

List<String> strings = ...;
String anyString = Lists.oneOf(strings);

Maps

sir.wellington.alchemy.collections.maps.Maps

Create

Map<Integer, String> map = Maps.create();

Map<Integer, String> defensiveCopy = Maps.immutableCopyOf(map);

Merge

Map<String, Object> first = ...;
Map<String, Object> second = ...;
Map<String, Object> merged = Maps.merge(first, second);

Sets

sir.wellington.alchemy.collections.sets.Sets

Union

A Union combines two or more sets into one.

Set<String> first = Sets.createFrom("one", "two", "three");
Set<String> second = Sets.createFrom("four", "crab");
Set<String> union = Sets.unionOf(first, second);
// {"one", "two", "three", "four", crab"}

Intersection

An Intersection finds the elements in common between two or more sets.

Set<String> first = Sets.createFrom("You", "Are", "What", "You", "Create");
Set<String> second = Sets.createFrom("What", "You", "Create", "Creates" "You");
Set<String> intersection = Sets.intersectionOf(first, second);
//{ "You", "Create"}

Requirements

  • Java 8
  • Maven

Building

This project builds with maven. Just run a mvn clean install to compile and install to your local maven repository

Release Notes

1.1

1.0

Initial Public Release.

License

This Software is licensed under the Apache 2.0 License

http://www.apache.org/licenses/LICENSE-2.0