Skip to content

Commit

Permalink
Moving capsule factory methods to sub-interfaces.
Browse files Browse the repository at this point in the history
  • Loading branch information
msteindorfer committed Mar 3, 2017
1 parent b0d28a6 commit d3c6793
Show file tree
Hide file tree
Showing 39 changed files with 1,082 additions and 843 deletions.
128 changes: 64 additions & 64 deletions capsule-core/src/main/java/io/usethesource/capsule/Map.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,18 @@ interface Immutable<K, V> extends Map<K, V>, MapEq.Immutable<K, V> {

Map.Transient<K, V> asTransient();

static <K, V> Map.Immutable<K, V> of() {
return PersistentTrieMap.of();
}

static <K, V> Map.Immutable<K, V> of(K key, V value) {
return PersistentTrieMap.of(key, value);
}

static <K, V> Map.Immutable<K, V> of(K key0, V value0, K key1, V value1) {
return PersistentTrieMap.of(key0, value0, key1, value1);
}

}

interface Transient<K, V> extends Map<K, V>, MapEq.Transient<K, V> {
Expand Down Expand Up @@ -79,89 +91,77 @@ interface Transient<K, V> extends Map<K, V>, MapEq.Transient<K, V> {

Map.Immutable<K, V> freeze();

}

static <K, V> Map.Immutable<K, V> of() {
return PersistentTrieMap.of();
}

static <K, V> Map.Immutable<K, V> of(K key, V value) {
return PersistentTrieMap.of(key, value);
}

static <K, V> Map.Immutable<K, V> of(K key0, V value0, K key1, V value1) {
return PersistentTrieMap.of(key0, value0, key1, value1);
}
static <K, V> Map.Transient<K, V> of() {
return PersistentTrieMap.transientOf();
}

static <K, V> Map.Transient<K, V> transientOf() {
return PersistentTrieMap.transientOf();
}
static <K, V> Map.Transient<K, V> of(K key0, V value0) {
final Map.Transient<K, V> tmp = Map.Transient.of();

static <K, V> Map.Transient<K, V> transientOf(K key0, V value0) {
final Map.Transient<K, V> tmp = Map.transientOf();
tmp.__put(key0, value0);

tmp.__put(key0, value0);
return tmp;
}

return tmp;
}
static <K, V> Map.Transient<K, V> of(K key0, V value0, K key1, V value1) {
final Map.Transient<K, V> tmp = Map.Transient.of();

static <K, V> Map.Transient<K, V> transientOf(K key0, V value0, K key1, V value1) {
final Map.Transient<K, V> tmp = Map.transientOf();
tmp.__put(key0, value0);
tmp.__put(key1, value1);

tmp.__put(key0, value0);
tmp.__put(key1, value1);
return tmp;
}

return tmp;
}
static <K, V> Map.Transient<K, V> of(K key0, V value0, K key1, V value1, K key2,
V value2) {
final Map.Transient<K, V> tmp = Map.Transient.of();

static <K, V> Map.Transient<K, V> transientOf(K key0, V value0, K key1, V value1, K key2,
V value2) {
final Map.Transient<K, V> tmp = Map.transientOf();
tmp.__put(key0, value0);
tmp.__put(key1, value1);
tmp.__put(key2, value2);

tmp.__put(key0, value0);
tmp.__put(key1, value1);
tmp.__put(key2, value2);
return tmp;
}

return tmp;
}
static <K, V> Map.Transient<K, V> of(K key0, V value0, K key1, V value1, K key2,
V value2, K key3, V value3) {
final Map.Transient<K, V> tmp = Map.Transient.of();

static <K, V> Map.Transient<K, V> transientOf(K key0, V value0, K key1, V value1, K key2,
V value2, K key3, V value3) {
final Map.Transient<K, V> tmp = Map.transientOf();
tmp.__put(key0, value0);
tmp.__put(key1, value1);
tmp.__put(key2, value2);
tmp.__put(key3, value3);

tmp.__put(key0, value0);
tmp.__put(key1, value1);
tmp.__put(key2, value2);
tmp.__put(key3, value3);
return tmp;
}

return tmp;
}
static <K, V> Map.Transient<K, V> of(K key0, V value0, K key1, V value1, K key2,
V value2, K key3, V value3, K key4, V value4) {
final Map.Transient<K, V> tmp = Map.Transient.of();

static <K, V> Map.Transient<K, V> transientOf(K key0, V value0, K key1, V value1, K key2,
V value2, K key3, V value3, K key4, V value4) {
final Map.Transient<K, V> tmp = Map.transientOf();
tmp.__put(key0, value0);
tmp.__put(key1, value1);
tmp.__put(key2, value2);
tmp.__put(key3, value3);
tmp.__put(key4, value4);

tmp.__put(key0, value0);
tmp.__put(key1, value1);
tmp.__put(key2, value2);
tmp.__put(key3, value3);
tmp.__put(key4, value4);
return tmp;
}

return tmp;
}
static <K, V> Map.Transient<K, V> of(K key0, V value0, K key1, V value1, K key2,
V value2, K key3, V value3, K key4, V value4, K key5, V value5) {
final Map.Transient<K, V> tmp = Map.Transient.of();

static <K, V> Map.Transient<K, V> transientOf(K key0, V value0, K key1, V value1, K key2,
V value2, K key3, V value3, K key4, V value4, K key5, V value5) {
final Map.Transient<K, V> tmp = Map.transientOf();
tmp.__put(key0, value0);
tmp.__put(key1, value1);
tmp.__put(key2, value2);
tmp.__put(key3, value3);
tmp.__put(key4, value4);
tmp.__put(key5, value5);

tmp.__put(key0, value0);
tmp.__put(key1, value1);
tmp.__put(key2, value2);
tmp.__put(key3, value3);
tmp.__put(key4, value4);
tmp.__put(key5, value5);
return tmp;
}

return tmp;
}

}
120 changes: 60 additions & 60 deletions capsule-core/src/main/java/io/usethesource/capsule/Set.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,18 @@ interface Immutable<K> extends Set<K>, SetEq.Immutable<K> {

Set.Transient<K> asTransient();

static <K> Set.Immutable<K> of() {
return PersistentTrieSet.of();
}

static <K> Set.Immutable<K> of(K item) {
return PersistentTrieSet.of(item);
}

static <K> Set.Immutable<K> of(K item0, K item1) {
return PersistentTrieSet.of(item0, item1);
}

}

interface Transient<K> extends Set<K>, SetEq.Transient<K> {
Expand All @@ -62,85 +74,73 @@ interface Transient<K> extends Set<K>, SetEq.Transient<K> {

Set.Immutable<K> freeze();

}

static <K> Set.Immutable<K> of() {
return PersistentTrieSet.of();
}

static <K> Set.Immutable<K> of(K item) {
return PersistentTrieSet.of(item);
}

static <K> Set.Immutable<K> of(K item0, K item1) {
return PersistentTrieSet.of(item0, item1);
}
static <K> Set.Transient<K> of() {
return PersistentTrieSet.transientOf();
}

static <K> Set.Transient<K> transientOf() {
return PersistentTrieSet.transientOf();
}
static <K> Set.Transient<K> of(K key0) {
final Set.Transient<K> tmp = Set.Transient.of();

static <K> Set.Transient<K> transientOf(K key0) {
final Set.Transient<K> tmp = Set.transientOf();
tmp.__insert(key0);

tmp.__insert(key0);
return tmp;
}

return tmp;
}
static <K> Set.Transient<K> of(K key0, K key1) {
final Set.Transient<K> tmp = Set.Transient.of();

static <K> Set.Transient<K> transientOf(K key0, K key1) {
final Set.Transient<K> tmp = Set.transientOf();
tmp.__insert(key0);
tmp.__insert(key1);

tmp.__insert(key0);
tmp.__insert(key1);
return tmp;
}

return tmp;
}
static <K> Set.Transient<K> of(K key0, K key1, K key2) {
final Set.Transient<K> tmp = Set.Transient.of();

static <K> Set.Transient<K> transientOf(K key0, K key1, K key2) {
final Set.Transient<K> tmp = Set.transientOf();
tmp.__insert(key0);
tmp.__insert(key1);
tmp.__insert(key2);

tmp.__insert(key0);
tmp.__insert(key1);
tmp.__insert(key2);
return tmp;
}

return tmp;
}
static <K> Set.Transient<K> of(K key0, K key1, K key2, K key3) {
final Set.Transient<K> tmp = Set.Transient.of();

static <K> Set.Transient<K> transientOf(K key0, K key1, K key2, K key3) {
final Set.Transient<K> tmp = Set.transientOf();
tmp.__insert(key0);
tmp.__insert(key1);
tmp.__insert(key2);
tmp.__insert(key3);

tmp.__insert(key0);
tmp.__insert(key1);
tmp.__insert(key2);
tmp.__insert(key3);
return tmp;
}

return tmp;
}
static <K> Set.Transient<K> of(K key0, K key1, K key2, K key3, K key4) {
final Set.Transient<K> tmp = Set.Transient.of();

static <K> Set.Transient<K> transientOf(K key0, K key1, K key2, K key3, K key4) {
final Set.Transient<K> tmp = Set.transientOf();
tmp.__insert(key0);
tmp.__insert(key1);
tmp.__insert(key2);
tmp.__insert(key3);
tmp.__insert(key4);

tmp.__insert(key0);
tmp.__insert(key1);
tmp.__insert(key2);
tmp.__insert(key3);
tmp.__insert(key4);
return tmp;
}

return tmp;
}
static <K> Set.Transient<K> of(K key0, K key1, K key2, K key3, K key4, K key5) {
final Set.Transient<K> tmp = Set.Transient.of();

static <K> Set.Transient<K> transientOf(K key0, K key1, K key2, K key3, K key4, K key5) {
final Set.Transient<K> tmp = Set.transientOf();
tmp.__insert(key0);
tmp.__insert(key1);
tmp.__insert(key2);
tmp.__insert(key3);
tmp.__insert(key4);
tmp.__insert(key5);

tmp.__insert(key0);
tmp.__insert(key1);
tmp.__insert(key2);
tmp.__insert(key3);
tmp.__insert(key4);
tmp.__insert(key5);
return tmp;
}

return tmp;
}

}
48 changes: 24 additions & 24 deletions capsule-core/src/main/java/io/usethesource/capsule/SetMultimap.java
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,23 @@ default SetMultimap.Immutable<K, V> complement(

SetMultimap.Transient<K, V> asTransient();

static <K, V> SetMultimap.Immutable<K, V> of() {
return PersistentTrieSetMultimap.of();
}

static <K, V> SetMultimap.Immutable<K, V> of(K key, V value) {
return PersistentTrieSetMultimap.of(key, value);
}

static <K, V> SetMultimap.Immutable<K, V> of(K key0, V value0, K key1, V value1) {
return PersistentTrieSetMultimap.of(key0, value0, key1, value1);
}

@Deprecated
static <K, V> SetMultimap.Immutable<K, V> of(EqualityComparator<Object> cmp) {
return PersistentTrieSetMultimap.of(cmp);
}

}

/*
Expand Down Expand Up @@ -188,32 +205,15 @@ default boolean complement(final SetMultimap<? extends K, ? extends V> setMultim

SetMultimap.Immutable<K, V> freeze();

}

static <K, V> SetMultimap.Immutable<K, V> of() {
return PersistentTrieSetMultimap.of();
}

static <K, V> SetMultimap.Immutable<K, V> of(K key, V value) {
return PersistentTrieSetMultimap.of(key, value);
}

static <K, V> SetMultimap.Immutable<K, V> of(K key0, V value0, K key1, V value1) {
return PersistentTrieSetMultimap.of(key0, value0, key1, value1);
}

static <K, V> SetMultimap.Transient<K, V> transientOf() {
return PersistentTrieSetMultimap.transientOf();
}
static <K, V> SetMultimap.Transient<K, V> of() {
return PersistentTrieSetMultimap.transientOf();
}

@Deprecated
static <K, V> SetMultimap.Immutable<K, V> of(EqualityComparator<Object> cmp) {
return PersistentTrieSetMultimap.of(cmp);
}
@Deprecated
static <K, V> SetMultimap.Transient<K, V> of(EqualityComparator<Object> cmp) {
return PersistentTrieSetMultimap.transientOf(cmp);
}

@Deprecated
static <K, V> SetMultimap.Transient<K, V> transientOf(EqualityComparator<Object> cmp) {
return PersistentTrieSetMultimap.transientOf(cmp);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public static final <K, V> BinaryRelation.Immutable<K, V> of() {
*
* TODO: make classes of nested multi-maps configurable.
*/
return new PersistentBidirectionalTrieSetMultimap<K, V>(SetMultimap.of(),
SetMultimap.of());
return new PersistentBidirectionalTrieSetMultimap<K, V>(SetMultimap.Immutable.of(),
SetMultimap.Immutable.of());
}

public static final <K, V> BinaryRelation.Transient<K, V> transientOf() {
Expand All @@ -45,8 +45,8 @@ public static final <K, V> BinaryRelation.Transient<K, V> transientOf() {
*
* TODO: make classes of nested multi-maps configurable.
*/
return new TransientBidirectionalTrieSetMultimap<K, V>(SetMultimap.transientOf(),
SetMultimap.transientOf());
return new TransientBidirectionalTrieSetMultimap<K, V>(SetMultimap.Transient.of(),
SetMultimap.Transient.of());
}

private static <K, V> BinaryRelation.Immutable<K, V> wireTuple(K key, V value,
Expand Down
Loading

0 comments on commit d3c6793

Please sign in to comment.