Skip to content

Commit

Permalink
code quality
Browse files Browse the repository at this point in the history
  • Loading branch information
pmeisen committed Jun 6, 2017
1 parent 52af11d commit de3888d
Show file tree
Hide file tree
Showing 26 changed files with 511 additions and 490 deletions.
2 changes: 1 addition & 1 deletion src/com/brein/time/exceptions/FailedConnection.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.brein.time.exceptions;

public class FailedConnection extends RuntimeException {
public class FailedConnection extends RuntimeException {

public FailedConnection() {
super();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,6 @@ public IntervalCollection load(final String key) {
return result;
}

public long size() {
return this.cache.estimatedSize();
}

public void clear() {
this.cache.cleanUp();
}

@Override
public void writeExternal(final ObjectOutput out) throws IOException {
super.writeExternal(out);
Expand All @@ -80,4 +72,12 @@ public void readExternal(final ObjectInput in) throws IOException, ClassNotFound
final TimeUnit timeUnit = TimeUnit.class.cast(in.readObject());
this.cache = createCache(cacheSize, expire, timeUnit);
}

public long size() {
return this.cache.estimatedSize();
}

public void clear() {
this.cache.cleanUp();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,28 +28,6 @@ public ObservableIntervalCollection(final IntervalCollectionObserver observer,
this.collection = collection;
}

@Override
public Collection<IInterval> find(final IInterval interval, final IntervalValueComparator cmp) {
return this.collection.find(interval, cmp);
}

@Override
public Collection<IInterval> find(final IInterval interval,
final IntervalValueComparator cmp,
final IntervalFilter filter) {
return this.collection.find(interval, cmp, filter);
}

@Override
public boolean isEmpty() {
return this.collection.isEmpty();
}

@Override
public int size() {
return this.collection.size();
}

@Override
@SuppressWarnings("NullableProblems")
public Iterator<IInterval> iterator() {
Expand Down Expand Up @@ -80,6 +58,33 @@ public boolean remove(final IInterval interval) {
return notifyObservers(interval, IntervalCollectionEventType.REMOVED, this.collection.remove(interval));
}

@Override
public boolean isEmpty() {
return this.collection.isEmpty();
}

@Override
public int size() {
return this.collection.size();
}

@Override
public Collection<IInterval> find(final IInterval interval, final IntervalValueComparator cmp) {
return this.collection.find(interval, cmp);
}

@Override
public Collection<IInterval> find(final IInterval interval,
final IntervalValueComparator cmp,
final IntervalFilter filter) {
return this.collection.find(interval, cmp, filter);
}

@Override
public Stream<IInterval> stream() {
return this.collection.stream();
}

public boolean notifyObservers(final IInterval interval,
final IntervalCollectionEventType eventType,
final boolean result) {
Expand All @@ -104,6 +109,11 @@ public boolean notifyObservers(final IInterval interval,
return true;
}

@Override
public int hashCode() {
return this.collection.hashCode();
}

@Override
public boolean equals(final Object obj) {
if (obj == this) {
Expand All @@ -118,16 +128,6 @@ public boolean equals(final Object obj) {
}
}

@Override
public int hashCode() {
return this.collection.hashCode();
}

@Override
public Stream<IInterval> stream() {
return this.collection.stream();
}

@Override
public String toString() {
return this.collection.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,6 @@
public class ShallowIntervalCollection implements IntervalCollection {
public static final ShallowIntervalCollection SHALLOW_COLLECTION = new ShallowIntervalCollection();

@Override
public boolean isEmpty() {
return true;
}

@Override
public int size() {
return 0;
}

@Override
public Iterator<IInterval> iterator() {
return Collections.emptyIterator();
Expand All @@ -36,6 +26,16 @@ public boolean remove(final IInterval o) {
return false;
}

@Override
public boolean isEmpty() {
return true;
}

@Override
public int size() {
return 0;
}

@Override
public Collection<IInterval> find(final IInterval interval,
final IntervalValueComparator cmp) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,6 @@ public boolean remove(final IInterval interval) {
throw new IllegalStateException("Collection is unmodifiable.");
}

@Override
public Iterator<IInterval> iterator() {
final Iterator<IInterval> it = wrappedCollection.iterator();
return new Iterator<IInterval>() {

@Override
public boolean hasNext() {
return it.hasNext();
}

@Override
public IInterval next() {
return it.next();
}
};
}

@Override
public boolean isEmpty() {
return wrappedCollection.isEmpty();
Expand Down Expand Up @@ -74,4 +57,21 @@ public Stream<IInterval> stream() {
public String getUniqueIdentifier() {
return wrappedCollection.getUniqueIdentifier();
}

@Override
public Iterator<IInterval> iterator() {
final Iterator<IInterval> it = wrappedCollection.iterator();
return new Iterator<IInterval>() {

@Override
public boolean hasNext() {
return it.hasNext();
}

@Override
public IInterval next() {
return it.next();
}
};
}
}
Loading

0 comments on commit de3888d

Please sign in to comment.