Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #113 from LarryHsiao/constant_source
Constant source
- Loading branch information
Showing
3 changed files
with
35 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,16 @@ | ||
package com.larryhsiao.clotho; | ||
|
||
/** | ||
* Constant source | ||
*/ | ||
public class ConstSource<T> implements Source<T> { | ||
|
||
private final T constant; | ||
|
||
public ConstSource(T constant) {this.constant = constant;} | ||
|
||
@Override | ||
public T value() throws Exception { | ||
return constant; | ||
} | ||
} |
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,18 @@ | ||
package com.larryhsiao.clotho; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
/** | ||
* Test for {@link ConstSource}. | ||
*/ | ||
class ConstSourceTest { | ||
@Test | ||
void inputEqualsOutput() throws Exception { | ||
final Object object = new Object(); | ||
Assertions.assertEquals( | ||
object, | ||
new ConstSource<>(object).value() | ||
); | ||
} | ||
} |