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

Make interfaces Serializable #1892

Merged
merged 2 commits into from
Mar 5, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 2 additions & 1 deletion javaslang/src/main/java/javaslang/collection/Map.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import javaslang.Tuple3;
import javaslang.control.Option;

import java.io.Serializable;
import java.util.*;
import java.util.function.*;

Expand Down Expand Up @@ -82,7 +83,7 @@
* @author Daniel Dietrich, Ruslan Sennov
* @since 2.0.0
*/
public interface Map<K, V> extends Traversable<Tuple2<K, V>>, Function1<K, V> {
public interface Map<K, V> extends Traversable<Tuple2<K, V>>, Function1<K, V>, Serializable {

long serialVersionUID = 1L;

Expand Down
3 changes: 2 additions & 1 deletion javaslang/src/main/java/javaslang/collection/Multimap.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import javaslang.*;
import javaslang.control.Option;

import java.io.Serializable;
import java.util.*;
import java.util.function.*;

Expand Down Expand Up @@ -73,7 +74,7 @@
* @author Ruslan Sennov
* @since 2.1.0
*/
public interface Multimap<K, V> extends Traversable<Tuple2<K, V>>, Function1<K, Traversable<V>>, Kind2<Multimap<?, ?>, K, V> {
public interface Multimap<K, V> extends Traversable<Tuple2<K, V>>, Function1<K, Traversable<V>>, Kind2<Multimap<?, ?>, K, V>, Serializable {

long serialVersionUID = 1L;

Expand Down
3 changes: 2 additions & 1 deletion javaslang/src/main/java/javaslang/collection/Seq.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import javaslang.Tuple3;
import javaslang.control.Option;

import java.io.Serializable;
import java.util.Comparator;
import java.util.Objects;
import java.util.function.*;
Expand Down Expand Up @@ -87,7 +88,7 @@
* @author Daniel Dietrich
* @since 1.1.0
*/
public interface Seq<T> extends Traversable<T>, Function1<Integer, T> {
public interface Seq<T> extends Traversable<T>, Function1<Integer, T>, Serializable {

long serialVersionUID = 1L;

Expand Down
3 changes: 2 additions & 1 deletion javaslang/src/main/java/javaslang/collection/Set.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import javaslang.Tuple3;
import javaslang.control.Option;

import java.io.Serializable;
import java.util.Comparator;
import java.util.Spliterator;
import java.util.Spliterators;
Expand Down Expand Up @@ -69,7 +70,7 @@
* @author Daniel Dietrich, Ruslan Sennov
* @since 2.0.0
*/
public interface Set<T> extends Traversable<T>, Function1<T, Boolean> {
public interface Set<T> extends Traversable<T>, Function1<T, Boolean>, Serializable {

long serialVersionUID = 1L;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import javaslang.Value;
import javaslang.control.Option;

import java.io.Serializable;
import java.math.BigInteger;
import java.util.Comparator;
import java.util.NoSuchElementException;
Expand Down
4 changes: 3 additions & 1 deletion javaslang/src/main/java/javaslang/collection/Tree.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
* @author Daniel Dietrich, Grzegorz Piwowarek
* @since 1.1.0
*/
public interface Tree<T> extends Traversable<T> {
public interface Tree<T> extends Traversable<T>, Serializable {

long serialVersionUID = 1L;

/**
* Returns a {@link java.util.stream.Collector} which may be used in conjunction with
Expand Down
4 changes: 3 additions & 1 deletion javaslang/src/main/java/javaslang/control/Either.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@
* @author Daniel Dietrich
* @since 1.0.0
*/
public interface Either<L, R> extends Value<R> {
public interface Either<L, R> extends Value<R>, Serializable {

long serialVersionUID = 1L;

/**
* Constructs a {@link Right}
Expand Down
4 changes: 3 additions & 1 deletion javaslang/src/main/java/javaslang/control/Option.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@
* @author Daniel Dietrich
* @since 1.0.0
*/
public interface Option<T> extends Value<T> {
public interface Option<T> extends Value<T>, Serializable {

long serialVersionUID = 1L;

/**
* Creates a new {@code Option} of a given value.
Expand Down
4 changes: 3 additions & 1 deletion javaslang/src/main/java/javaslang/control/Try.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
* @author Daniel Dietrich
* @since 1.0.0
*/
public interface Try<T> extends Value<T> {
public interface Try<T> extends Value<T>, Serializable {

long serialVersionUID = 1L;

/**
* Creates a Try of a CheckedSupplier.
Expand Down
4 changes: 3 additions & 1 deletion javaslang/src/main/java/javaslang/control/Validation.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@
* @see <a href="https://github.com/scalaz/scalaz/blob/series/7.3.x/core/src/main/scala/scalaz/Validation.scala">Validation</a>
* @since 2.0.0
*/
public interface Validation<E, T> extends Value<T> {
public interface Validation<E, T> extends Value<T>, Serializable {

long serialVersionUID = 1L;

/**
* Creates a {@link Valid} that contains the given {@code value}.
Expand Down
8 changes: 4 additions & 4 deletions javaslang/src/test/java/javaslang/AbstractValueTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ protected StringAssert assertThat(String actual) {
@SuppressWarnings("unchecked")
abstract protected <T> Value<T> of(T... elements);

// TODO: Eliminate this method. Switching the behavior of unit tests is evil. Tests should not contain additional logic.
// TODO: Eliminate this method. Switching the behavior of unit tests is evil. Tests should not contain additional logic. Also it seems currently to be used in different sematic contexts.
abstract protected boolean useIsEqualToInsteadOfIsSameAs();

// returns the peek result of the specific Traversable implementation
Expand Down Expand Up @@ -981,14 +981,14 @@ private boolean isSerializable() {
instanceOf(Either.LeftProjection.class),
instanceOf(Either.RightProjection.class),
instanceOf(Future.class),
instanceOf(Iterator.class),
instanceOf(Validation.class)
instanceOf(Iterator.class)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Matches before instanceOf(Traversable.class) is checked, so it is ok.

), false),
Case(anyOf(
instanceOf(Either.class),
instanceOf(Option.class),
instanceOf(Try.class),
instanceOf(Traversable.class)
instanceOf(Traversable.class),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In 3.0.0 Iterator will not implement Traversable any more (i.e. all internal ofAll(iterator) calls will be substituted with ofAll(() -> iterator)). So all Traversables will be Serializable.

instanceOf(Validation.class)
), true)
);
assertThat(actual).isEqualTo(expected);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected final <T> Value<T> of(T... elements) {

@Override
protected boolean useIsEqualToInsteadOfIsSameAs() {
return false;
return true;
}

@Override
Expand Down