Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup: final and utility classes #1747

Merged
merged 1 commit into from
Oct 10, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/rx/Notification.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*
* @see <a href="http://msdn.microsoft.com/en-us/library/hh229462.aspx">the Microsoft Rx equivalent</a>
*/
public class Notification<T> {
public final class Notification<T> {

private final Kind kind;
private final Throwable throwable;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/rx/exceptions/Exceptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
/**
* @warn javadoc class description missing
*/
public class Exceptions {
public final class Exceptions {
private Exceptions() {

}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/rx/exceptions/OnErrorThrowable.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* recover more information from an {@code OnErrorThrowable} than is found in a typical {@code Throwable}, such
* as the item the {@code Observable} was trying to emit at the time the error was encountered.
*/
public class OnErrorThrowable extends RuntimeException {
public final class OnErrorThrowable extends RuntimeException {

private static final long serialVersionUID = -569558213262703934L;

Expand Down
5 changes: 4 additions & 1 deletion src/main/java/rx/functions/Functions.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
*/
package rx.functions;

public class Functions {
public final class Functions {
private Functions() {
throw new IllegalStateException("No instances!");
}

/**
* Converts a {@link Func0} to a {@link FuncN} to allow heterogeneous handling of functions with different
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
* <img width="640" src="https://github.com/ReactiveX/RxJava/wiki/images/rx-operators/B.mostRecent.png" alt="">
*/
public final class BlockingOperatorMostRecent {

private BlockingOperatorMostRecent() {
throw new IllegalStateException("No instances!");
}
/**
* Returns an {@code Iterable} that always returns the item most recently emitted by the {@code Observable}.
*
Expand Down Expand Up @@ -58,7 +60,7 @@ public Iterator<T> iterator() {
};
}

private static class MostRecentObserver<T> extends Subscriber<T> {
private static final class MostRecentObserver<T> extends Subscriber<T> {
final NotificationLite<T> nl = NotificationLite.instance();
volatile Object value;

Expand Down
3 changes: 3 additions & 0 deletions src/main/java/rx/internal/operators/BlockingOperatorNext.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
* <img width="640" src="https://github.com/ReactiveX/RxJava/wiki/images/rx-operators/B.next.png" alt="">
*/
public final class BlockingOperatorNext {
private BlockingOperatorNext() {
throw new IllegalStateException("No instances!");
}

/**
* Returns an {@code Iterable} that blocks until the {@code Observable} emits another item, then returns
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@
* The toFuture operation throws an exception if the Observable emits more than one item. If the
* Observable may emit more than item, use <code>toList().toFuture()</code>.
*/
public class BlockingOperatorToFuture {

public final class BlockingOperatorToFuture {
private BlockingOperatorToFuture() {
throw new IllegalStateException("No instances!");
}
/**
* Returns a Future that expects a single item from the observable.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@
*
* @see <a href="https://github.com/ReactiveX/RxJava/issues/50">Issue #50</a>
*/
public class BlockingOperatorToIterator {
public final class BlockingOperatorToIterator {
private BlockingOperatorToIterator() {
throw new IllegalStateException("No instances!");
}

/**
* Returns an iterator that iterates all values of the observable.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
* @param <T>
* the type of the items to be buffered
*/
public class BufferUntilSubscriber<T> extends Subject<T, T> {
public final class BufferUntilSubscriber<T> extends Subject<T, T> {

@SuppressWarnings("rawtypes")
private final static Observer EMPTY_OBSERVER = new EmptyObserver();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@
* This is blocking so the {@code Subscription} returned when calling
* {@code Observable.unsafeSubscribe(Observer)} does nothing.
*/
public class OnSubscribeToObservableFuture {
public final class OnSubscribeToObservableFuture {
private OnSubscribeToObservableFuture() {
throw new IllegalStateException("No instances!");
}

/* package accessible for unit tests */static class ToObservableFuture<T> implements OnSubscribe<T> {
private final Future<? extends T> that;
private final long time;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public Subscriber<? super T> call(Subscriber<? super T> subscriber) {
return timeoutSubscriber;
}

/* package-private */static class TimeoutSubscriber<T> extends
/* package-private */static final class TimeoutSubscriber<T> extends
Subscriber<T> {

private final SerialSubscription serial;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/rx/internal/util/IndexedRingBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
*
* @param <E>
*/
public class IndexedRingBuffer<E> implements Subscription {
public final class IndexedRingBuffer<E> implements Subscription {

private static final ObjectPool<IndexedRingBuffer> POOL = new ObjectPool<IndexedRingBuffer>() {

Expand Down
5 changes: 4 additions & 1 deletion src/main/java/rx/internal/util/unsafe/Pow2.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
*/
package rx.internal.util.unsafe;

public class Pow2 {
public final class Pow2 {
private Pow2() {
throw new IllegalStateException("No instances!");
}

/**
* Find the next larger positive power of two value up from the given value. If value is a power of two then
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/rx/internal/util/unsafe/UnsafeAccess.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
* otherwise NPEs will happen in environments without "suc.misc.Unsafe" such as Android.
*/
public final class UnsafeAccess {
private UnsafeAccess() {
throw new IllegalStateException("No instances!");
}

public static final Unsafe UNSAFE;
static {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/rx/observables/BlockingObservable.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
* @param <T>
* the type of item emitted by the {@code BlockingObservable}
*/
public class BlockingObservable<T> {
public final class BlockingObservable<T> {

private final Observable<? extends T> o;

Expand Down
5 changes: 4 additions & 1 deletion src/main/java/rx/observers/Observers.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@
/**
* Helper methods and utilities for creating and working with {@link Observer} objects.
*/
public class Observers {
public final class Observers {
private Observers() {
throw new IllegalStateException("No instances!");
}

private static final Observer<Object> EMPTY = new Observer<Object>() {

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/rx/schedulers/NewThreadScheduler.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
/**
* Schedules work on a new thread.
*/
public class NewThreadScheduler extends Scheduler {
public final class NewThreadScheduler extends Scheduler {

private static final String THREAD_NAME_PREFIX = "RxNewThreadScheduler-";
private static final RxThreadFactory THREAD_FACTORY = new RxThreadFactory(THREAD_NAME_PREFIX);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/rx/schedulers/TestScheduler.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class TestScheduler extends Scheduler {
private final Queue<TimedAction> queue = new PriorityQueue<TimedAction>(11, new CompareActionsByTime());
private static long counter = 0;

private static class TimedAction {
private static final class TimedAction {

private final long time;
private final Action0 action;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/rx/schedulers/TrampolineScheduler.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public boolean isUnsubscribed() {

}

private static class TimedAction implements Comparable<TimedAction> {
private static final class TimedAction implements Comparable<TimedAction> {
final Action0 action;
final Long execTime;
final int count; // In case if time between enqueueing took less than 1ms
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/rx/subscriptions/Subscriptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
* Helper methods and utilities for creating and working with {@link Subscription} objects
*/
public final class Subscriptions {
private Subscriptions() {
throw new IllegalStateException("No instances!");
}
/**
* Returns a {@link Subscription} that does nothing.
*
Expand Down
6 changes: 4 additions & 2 deletions src/test/java/rx/EventStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@
/**
* Utility for retrieving a mock eventstream for testing.
*/
public class EventStream {

public final class EventStream {
private EventStream() {
throw new IllegalStateException("No instances!");
}
public static Observable<Event> getEventStream(final String type, final int numInstances) {
return Observable.create(new OnSubscribe<Event>() {

Expand Down
2 changes: 1 addition & 1 deletion src/test/java/rx/exceptions/OnNextValueTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* There is an added danger that if there is a bug in the toString method it will cause inconsistent exception creation. If the object throws an exception while rendering a string it will actually end up not seeing the real exception.
*/
public final class OnNextValueTest {
private static class BadToString {
private static final class BadToString {

private final boolean throwDuringToString;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public Worker createWorker() {
return new SlowInner(actual.createWorker());
}

private class SlowInner extends Worker {
private final class SlowInner extends Worker {

private final Scheduler.Worker actualInner;

Expand Down
2 changes: 1 addition & 1 deletion src/test/java/rx/test/OperatorTester.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
/**
* Common utility functions for testing operator implementations.
*/
public class OperatorTester {
public final class OperatorTester {
/*
* This is purposefully package-only so it does not leak into the public API outside of this package.
*
Expand Down
5 changes: 4 additions & 1 deletion src/test/java/rx/util/AssertObservable.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@
import rx.functions.Func1;
import rx.functions.Func2;

public class AssertObservable {
public final class AssertObservable {
private AssertObservable() {
throw new IllegalStateException("No instances!");
}
/**
* Asserts that two Observables are equal. If they are not, an {@link AssertionError} is thrown
* with the given message. If <code>expecteds</code> and <code>actuals</code> are
Expand Down