Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added automatic tests for Data and Value with generics
- Loading branch information
Michail Plushnikov
committed
Mar 25, 2016
1 parent
b7c8c86
commit 8b30698
Showing
9 changed files
with
196 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 8 additions & 6 deletions
14
.../de/plushnikov/data/DataWithGenerics.java → ...e/plushnikov/data/DataWithGeneric176.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,30 @@ | ||
package de.plushnikov.data; | ||
|
||
|
||
import lombok.Data; | ||
|
||
@Data | ||
public class DataWithGenerics<T> { | ||
@Data(staticConstructor = "of") | ||
public class DataWithGeneric176<T> { | ||
|
||
private final T command; | ||
private final Runnable callback; | ||
|
||
public static void main(String[] args) { | ||
DataWithGenerics<Integer> test = new DataWithGenerics<Integer>(123, new Runnable() { | ||
DataWithGeneric176<Integer> test = new DataWithGeneric176<Integer>(123, new Runnable() { | ||
@Override | ||
public void run() { | ||
System.out.println("Run"); | ||
} | ||
}); | ||
|
||
test.getCallback(); | ||
test.getCommand(); | ||
System.out.println(test.getCommand()); | ||
|
||
DataWithGenerics<String> foo = new DataWithGenerics<String>("fooqwqww", new Runnable() { | ||
DataWithGeneric176<String> foo = DataWithGeneric176.of("fooqwqww", new Runnable() { | ||
public void run() { | ||
} | ||
}); | ||
|
||
foo.getCallback(); | ||
System.out.println(foo.getCommand()); | ||
} | ||
} |
14 changes: 0 additions & 14 deletions
14
test-manual/src/main/java/de/plushnikov/value/Issue176.java
This file was deleted.
Oops, something went wrong.
14 changes: 14 additions & 0 deletions
14
test-manual/src/main/java/de/plushnikov/value/ValueWithGeneric176.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package de.plushnikov.value; | ||
|
||
import lombok.Value; | ||
|
||
@Value(staticConstructor = "of") | ||
public class ValueWithGeneric176<T> { | ||
private T name; | ||
private int count; | ||
|
||
public static void main(String[] args) { | ||
ValueWithGeneric176<String> valueObject = ValueWithGeneric176.of("thing1", 10); | ||
System.out.println(valueObject); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
public class DataWithGeneric176<T> { | ||
|
||
private final T command; | ||
private final Runnable callback; | ||
|
||
@java.beans.ConstructorProperties({"command", "callback"}) | ||
private DataWithGeneric176(T command, Runnable callback) { | ||
this.command = command; | ||
this.callback = callback; | ||
} | ||
|
||
public static void main(String[] args) { | ||
DataWithGeneric176<Integer> test = new DataWithGeneric176<Integer>(123, new Runnable() { | ||
@Override | ||
public void run() { | ||
System.out.println("Run"); | ||
} | ||
}); | ||
|
||
test.getCallback(); | ||
System.out.println(test.getCommand()); | ||
|
||
DataWithGeneric176<String> foo = DataWithGeneric176.of("fooqwqww", new Runnable() { | ||
public void run() { | ||
} | ||
}); | ||
|
||
foo.getCallback(); | ||
System.out.println(foo.getCommand()); | ||
} | ||
|
||
public static <T> DataWithGeneric176<T> of(T command, Runnable callback) { | ||
return new DataWithGeneric176<T>(command, callback); | ||
} | ||
|
||
public T getCommand() { | ||
return this.command; | ||
} | ||
|
||
public Runnable getCallback() { | ||
return this.callback; | ||
} | ||
|
||
public boolean equals(Object o) { | ||
if (o == this) return true; | ||
if (!(o instanceof DataWithGeneric176)) return false; | ||
final DataWithGeneric176 other = (DataWithGeneric176) o; | ||
if (!other.canEqual((Object) this)) return false; | ||
final Object this$command = this.command; | ||
final Object other$command = other.command; | ||
if (this$command == null ? other$command != null : !this$command.equals(other$command)) return false; | ||
final Object this$callback = this.callback; | ||
final Object other$callback = other.callback; | ||
if (this$callback == null ? other$callback != null : !this$callback.equals(other$callback)) return false; | ||
return true; | ||
} | ||
|
||
public int hashCode() { | ||
final int PRIME = 59; | ||
int result = 1; | ||
final Object $command = this.command; | ||
result = result * PRIME + ($command == null ? 0 : $command.hashCode()); | ||
final Object $callback = this.callback; | ||
result = result * PRIME + ($callback == null ? 0 : $callback.hashCode()); | ||
return result; | ||
} | ||
|
||
protected boolean canEqual(Object other) { | ||
return other instanceof DataWithGeneric176; | ||
} | ||
|
||
public String toString() { | ||
return "DataWithGeneric176(command=" + this.command + ", callback=" + this.callback + ")"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
public class ValueWithGeneric176<T> { | ||
private T name; | ||
private int count; | ||
|
||
@java.beans.ConstructorProperties({"name", "count"}) | ||
private ValueWithGeneric176(T name, int count) { | ||
this.name = name; | ||
this.count = count; | ||
} | ||
|
||
public static void main(String[] args) { | ||
ValueWithGeneric176<String> valueObject = ValueWithGeneric176.of("thing1", 10); | ||
System.out.println(valueObject); | ||
} | ||
|
||
public static <T> ValueWithGeneric176<T> of(T name, int count) { | ||
return new ValueWithGeneric176<T>(name, count); | ||
} | ||
|
||
public T getName() { | ||
return this.name; | ||
} | ||
|
||
public int getCount() { | ||
return this.count; | ||
} | ||
|
||
public boolean equals(Object o) { | ||
if (o == this) return true; | ||
if (!(o instanceof ValueWithGeneric176)) return false; | ||
final ValueWithGeneric176 other = (ValueWithGeneric176) o; | ||
final Object this$name = this.name; | ||
final Object other$name = other.name; | ||
if (this$name == null ? other$name != null : !this$name.equals(other$name)) return false; | ||
if (this.count != other.count) return false; | ||
return true; | ||
} | ||
|
||
public int hashCode() { | ||
final int PRIME = 59; | ||
int result = 1; | ||
final Object $name = this.name; | ||
result = result * PRIME + ($name == null ? 0 : $name.hashCode()); | ||
result = result * PRIME + this.count; | ||
return result; | ||
} | ||
|
||
public String toString() { | ||
return "ValueWithGeneric176(name=" + this.name + ", count=" + this.count + ")"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import lombok.Data; | ||
|
||
@Data(staticConstructor = "of") | ||
public class DataWithGeneric176<T> { | ||
|
||
private final T command; | ||
private final Runnable callback; | ||
|
||
public static void main(String[] args) { | ||
DataWithGeneric176<Integer> test = new DataWithGeneric176<Integer>(123, new Runnable() { | ||
@Override | ||
public void run() { | ||
System.out.println("Run"); | ||
} | ||
}); | ||
|
||
test.getCallback(); | ||
System.out.println(test.getCommand()); | ||
|
||
DataWithGeneric176<String> foo = DataWithGeneric176.of("fooqwqww", new Runnable() { | ||
public void run() { | ||
} | ||
}); | ||
|
||
foo.getCallback(); | ||
System.out.println(foo.getCommand()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import lombok.Value; | ||
|
||
@Value(staticConstructor = "of") | ||
public class ValueWithGeneric176<T> { | ||
private T name; | ||
private int count; | ||
|
||
public static void main(String[] args) { | ||
ValueWithGeneric176<String> valueObject = ValueWithGeneric176.of("thing1", 10); | ||
System.out.println(valueObject); | ||
} | ||
} |