Skip to content

Commit

Permalink
First refactorings done
Browse files Browse the repository at this point in the history
  • Loading branch information
igorakkerman committed May 18, 2016
1 parent ae272ba commit 76e082d
Show file tree
Hide file tree
Showing 74 changed files with 230 additions and 241 deletions.
2 changes: 1 addition & 1 deletion jlib-container.iml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<orderEntry type="module" module-name="jlib-array" />
<orderEntry type="module" module-name="jlib-operator" />
<orderEntry type="module" module-name="jlib-value" />
<orderEntry type="library" name="Maven: org.checkerframework:checker-qual:1.8.10" level="project" />
<orderEntry type="library" name="Maven: org.checkerframework:checker-qual:2.0.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.12" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.assertj:assertj-core:1.7.1" level="project" />
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
limitations under the License.
-->

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>
Expand Down
18 changes: 9 additions & 9 deletions src/main/java/org/jlib/container/Container.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@
import org.jlib.container.operation.ToSet;

public interface Container<Item>
extends Iterable<Item>,
ContainsSingle<Item>,
ContainsMultiple<Item>,
Count<Item>,
IsEmpty<Item>,
ToArray<Item>,
ToRandomAccessList<Item>,
ToSequentialList<Item>,
ToSet<Item> {
extends Iterable<Item>,
ContainsSingle<Item>,
ContainsMultiple<Item>,
Count<Item>,
IsEmpty<Item>,
ToArray<Item>,
ToRandomAccessList<Item>,
ToSequentialList<Item>,
ToSet<Item> {
// unifying
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.jlib.iterator.RemoveIterable;
import org.jlib.iterator.RemoveIterator;
import org.jlib.iterator.SingletonIterable;

import org.jlib.operator.observer.Observer;

/**
Expand All @@ -38,6 +37,8 @@
*/
public final class IterableUtility {

private IterableUtility() {}

/**
* Removes all Items of the specified {@link RemoveIterable}.
*
Expand All @@ -51,7 +52,7 @@ public final class IterableUtility {
* if an error occurs during one of the remove operations
*/
public static <Item> void removeAll(final RemoveIterable<Item> iterable)
throws InvalidIterableStateException {
throws InvalidIterableStateException {
for (final RemoveIterator<Item> iterator = iterable.iterator(); iterator.hasNext(); ) {
iterator.next();
iterator.remove();
Expand All @@ -77,7 +78,7 @@ public static <Item> void removeAll(final RemoveIterable<Item> iterable)
@SafeVarargs
public static <Item> void removeAll(final ObservedRemoveIterable<Item> iterable,
final Observer<Item>... observers)
throws InvalidIterableStateException {
throws InvalidIterableStateException {
for (final ObservedRemoveIterator<Item> iterator = iterable.iterator(); iterator.hasNext(); ) {
iterator.next();
iterator.remove(observers);
Expand All @@ -87,6 +88,4 @@ public static <Item> void removeAll(final ObservedRemoveIterable<Item> iterable,
public static <Item> BidiIterable<Item> singletonIterable(final Item item) {
return new SingletonIterable<>(item);
}

private IterableUtility() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* @author Igor Akkerman
*/
public class NoItemToReplaceException
extends InvalidIteratorStateException {
extends InvalidIteratorStateException {

private static final long serialVersionUID = - 1299720624484946758L;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* @author Igor Akkerman
*/
public interface ObservedRemoveIterable<Item>
extends RemoveIterable<Item> {
extends RemoveIterable<Item> {

/**
* Returns a new {@link ObservedRemoveIterator} over the Items of this {@link ObservedRemoveIterable}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import org.jlib.iterator.InvalidIterableStateException;
import org.jlib.iterator.NoItemToRemoveException;
import org.jlib.iterator.RemoveIterator;

import org.jlib.operator.observer.Observer;
import org.jlib.operator.observer.ObserverException;

Expand All @@ -38,7 +37,7 @@
* @author Igor Akkerman
*/
public interface ObservedRemoveIterator<Item>
extends RemoveIterator<Item> {
extends RemoveIterator<Item> {

/**
* Removes the last traversed Item.
Expand All @@ -62,7 +61,7 @@ public interface ObservedRemoveIterator<Item>
*/
@SuppressWarnings({ "unchecked", "DuplicateThrows" })
void remove(Observer<Item>... observers)
throws NoItemToRemoveException, InvalidIterableStateException, ObserverException, RuntimeException;
throws NoItemToRemoveException, InvalidIterableStateException, ObserverException, RuntimeException;

/**
* Registers the specified {@link Observer} for the remove operations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
* @author Igor Akkerman
*/
public interface ObservedReplaceIterable<Item>
extends ReplaceIterable<Item> {
extends ReplaceIterable<Item> {

/**
* Returns a new {@link ObservedReplaceIterator} over the Items of this {@link ObservedReplaceIterable}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* @author Igor Akkerman
*/
public interface ObservedReplaceIterator<Item>
extends ReplaceIterator<Item> {
extends ReplaceIterator<Item> {

/**
* Replaces the last traversed Item with the specified value.
Expand All @@ -54,7 +54,7 @@ public interface ObservedReplaceIterator<Item>
*/
@SuppressWarnings("unchecked")
void replace(Item newItem, Observer<Item>... observers)
throws NoItemToReplaceException, ObserverException;
throws NoItemToReplaceException, ObserverException;

/**
* Registers the specified {@link Observer} for the replace operations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
* @author Igor Akkerman
*/
public interface ObservedReplaceRemoveIterable<Item>
extends ReplaceRemoveIterator<Item>,
ObservedReplaceIterator<Item>,
ObservedRemoveIterator<Item> {
extends ReplaceRemoveIterator<Item>,
ObservedReplaceIterator<Item>,
ObservedRemoveIterator<Item> {

ObservedReplaceRemoveIterator<Item> iterator();
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
* @author Igor Akkerman
*/
public interface ObservedReplaceRemoveIterator<Item>
extends ReplaceRemoveIterator<Item>,
ObservedReplaceIterator<Item>,
ObservedRemoveIterator<Item> {
extends ReplaceRemoveIterator<Item>,
ObservedReplaceIterator<Item>,
ObservedRemoveIterator<Item> {
// unifying interface
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
* @author Igor Akkerman
*/
public interface ReplaceIterable<Item>
extends Iterable<Item> {
extends Iterable<Item> {

/**
* Returns a new {@link ReplaceIterator} over the Items of this {@link ReplaceIterable}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* @author Igor Akkerman
*/
public interface ReplaceIterator<Item>
extends Iterator<Item> {
extends Iterator<Item> {

/**
* Replaces the last traversed Item with the specified Item.
Expand All @@ -46,5 +46,5 @@ public interface ReplaceIterator<Item>
* if no Item has been traversed by this {@link ReplaceIterator}
*/
void replace(Item newItem)
throws InvalidIteratorStateException;
throws InvalidIteratorStateException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
* @author Igor Akkerman
*/
public interface ReplaceRemoveIterable<Item>
extends ReplaceIterable<Item>,
RemoveIterable<Item> {
extends ReplaceIterable<Item>,
RemoveIterable<Item> {

/**
* Returns a new {@link ReplaceRemoveIterator} over the Items of this {@link ReplaceRemoveIterable}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* @author Igor Akkerman
*/
public interface ReplaceRemoveIterator<Item>
extends ReplaceIterator<Item>,
RemoveIterator<Item> {
extends ReplaceIterator<Item>,
RemoveIterator<Item> {
// unifying interface
}
32 changes: 16 additions & 16 deletions src/main/java/org/jlib/container/operation/AlmightyContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,21 @@
package org.jlib.container.operation;

public interface AlmightyContainer<Item>
extends ContainsSingle<Item>,
ContainsMultiple<Item>,
Count<Item>,
IsEmpty<Item>,
ObservedRemoveMultiple<Item>,
ObservedRemoveAll<Item>,
ObservedRetain<Item>,
RemoveSingleByValue<Item>,
RemoveMultipleByValue<Item>,
RemoveAll<Item>,
Retain<Item>,
ToArray<Item>,
ToRandomAccessList<Item>,
ToSequentialList<Item>,
ToSet<Item>,
Iterable<Item> {
extends ContainsSingle<Item>,
ContainsMultiple<Item>,
Count<Item>,
IsEmpty<Item>,
ObservedRemoveMultiple<Item>,
ObservedRemoveAll<Item>,
ObservedRetain<Item>,
RemoveSingleByValue<Item>,
RemoveMultipleByValue<Item>,
RemoveAll<Item>,
Retain<Item>,
ToArray<Item>,
ToRandomAccessList<Item>,
ToSequentialList<Item>,
ToSet<Item>,
Iterable<Item> {
// unifying
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@
import org.jlib.basefunctions.HashCodeEngine;

public class BaseFunctionsIterableHashCode<Item>
implements HashCode<Iterable<Item>> {
implements HashCode<Iterable<Item>> {

private static final BaseFunctionsIterableHashCode<?> INSTANCE = new BaseFunctionsIterableHashCode<>();

private BaseFunctionsIterableHashCode() {}

@SuppressWarnings("unchecked")
public static <Item> BaseFunctionsIterableHashCode<Item> getInstance() {
return (BaseFunctionsIterableHashCode<Item>) INSTANCE;
}

private BaseFunctionsIterableHashCode() {}

@Override
public int hashCode(final Iterable<Item> items) {
final HashCodeEngine<Iterable<Item>> hashCodeEngine = /*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@ public interface ContainsMultiple<Item> {
*/
<ContainsIterable extends Iterable<Item> & ContainsSingle<Item>> /*
*/ boolean contains(ContainsIterable items)
throws InvalidContainerArgumentException, InvalidContainerStateException;
throws InvalidContainerArgumentException, InvalidContainerStateException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@
public interface ContainsSingle<Item> {

boolean contains(Item item)
throws InvalidContainerArgumentException, InvalidContainerStateException;
throws InvalidContainerArgumentException, InvalidContainerStateException;
}
5 changes: 2 additions & 3 deletions src/main/java/org/jlib/container/operation/Count.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@

package org.jlib.container.operation;

public interface Count<Item>
{
public interface Count<Item> {

/**
* Returns the number of Items in this {@link Object}.
Expand All @@ -33,5 +32,5 @@ public interface Count<Item>
* if an error occurs during the operation
*/
int count()
throws InvalidContainerStateException;
throws InvalidContainerStateException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
import org.jlib.basefunctions.ApplicationObject;

public final class CountIterableToArray<Item, DelegateContainer extends Count<Item> & Iterable<Item>>
extends ApplicationObject
implements ToArray<Item> {
extends ApplicationObject
implements ToArray<Item> {

private final DelegateContainer delegateIterable;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
package org.jlib.container.operation;

public class DefaultContainsMultiple<Item>
implements ContainsMultiple<Item> {
implements ContainsMultiple<Item> {

private final ContainsSingle<Item> containedItems;

Expand All @@ -34,7 +34,7 @@ public DefaultContainsMultiple(final ContainsSingle<Item> containedItems) {
@Override
public <ContainsIterable extends Iterable<Item> & ContainsSingle<Item>> /*
*/ boolean contains(final ContainsIterable lookupItems)
throws InvalidContainerArgumentException, InvalidContainerStateException {
throws InvalidContainerArgumentException, InvalidContainerStateException {

for (final Item lookupItem : lookupItems)
if (! containedItems.contains(lookupItem))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
package org.jlib.container.operation;

public class DefaultRemoveMultipleByMultiple<Item>
implements RemoveMultipleByValue<Item> {
implements RemoveMultipleByValue<Item> {

private final Iterable<Item> containedItems;

Expand All @@ -38,7 +38,7 @@ public class DefaultRemoveMultipleByMultiple<Item>
@Override
public <ContainsIterable extends Iterable<Item> & ContainsSingle<Item>> /*
*/ void remove(final ContainsIterable removedItems)
throws InvalidContainerArgumentException, InvalidContainerStateException {
throws InvalidContainerArgumentException, InvalidContainerStateException {

for (final Item containedItem : containedItems)
if (removedItems.contains(containedItem))
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/jlib/container/operation/DefaultRetain.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.jlib.container.operation.containsadapter.IterativeContainsAdapter;

public class DefaultRetain<Item>
implements Retain<Item> {
implements Retain<Item> {

private final RemoveSingleByValue<Item> removableContainedItems;

Expand All @@ -40,7 +40,7 @@ public class DefaultRetain<Item>
@Override
@SuppressWarnings("TypeMayBeWeakened")
public void retain(final IterativeContainsAdapter<Item> retainedItems)
throws InvalidContainerArgumentException, InvalidContainerStateException {
throws InvalidContainerArgumentException, InvalidContainerStateException {

for (final Item containedItem : containedItems)
if (! retainedItems.contains(containedItem))
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/jlib/container/operation/EqualCount.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ public class EqualCount<Item> {

private static final EqualCount<?> INSTANCE = new EqualCount<>();

private EqualCount() {}

@SuppressWarnings("unchecked")
public static <Item> EqualCount<Item> getInstance() {
return (EqualCount<Item>) INSTANCE;
}

private EqualCount() {}

public boolean haveEqualCount(final Count<Item> thisObject, @Nullable final Object otherObject) {
return otherObject instanceof Count<?> && //
thisObject.count() == ((Count<?>) otherObject).count();
Expand Down
Loading

0 comments on commit 76e082d

Please sign in to comment.