Merge pull request #37 from kemitix/cleanup

Cleanup
This commit is contained in:
Paul Campbell 2018-08-25 15:56:36 +01:00 committed by GitHub
commit 82e1c0fe4b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 58 additions and 93 deletions

View file

@ -4,7 +4,17 @@ CHANGELOG
0.7.0 0.7.0
----- -----
* Deprecate `Value.andNot(Supplier)` * Deprecate Value.andNot(Supplier)
* pom: Remove redundant properties
* Remove deprecated methods
* pom: rearrange entries
* Bump assertj-core from 3.10.0 to 3.11.0
* Bump lombok from 1.18.0 to 1.18.2
* Bump tiles-maven-plugin from 2.11 to 2.12
* README: update Value examples
* README: update Condition examples
* Value: cleanup deprecated whereNot()
* README: convert to orgmode format
0.6.0 0.6.0
----- -----

25
pom.xml
View file

@ -3,14 +3,18 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent>
<groupId>net.kemitix</groupId>
<artifactId>kemitix-parent</artifactId>
<version>5.1.1</version>
<relativePath/>
</parent>
<artifactId>conditional</artifactId>
<version>DEV-SNAPSHOT</version>
<properties> <properties>
<kemitix-checkstyle.version>4.1.1</kemitix-checkstyle.version> <kemitix-checkstyle.version>4.1.1</kemitix-checkstyle.version>
<kemitix.checkstyle.ruleset.level>5-complexity</kemitix.checkstyle.ruleset.level>
<jacoco-class-line-covered-ratio>1</jacoco-class-line-covered-ratio>
<jacoco-class-instruction-covered-ratio>1</jacoco-class-instruction-covered-ratio>
<jacoco-class-missed-count-maximum>0</jacoco-class-missed-count-maximum>
<pitest.coverage>100</pitest.coverage>
<pitest.mutation>100</pitest.mutation>
<junit.version>4.12</junit.version> <junit.version>4.12</junit.version>
<assertj.version>3.11.0</assertj.version> <assertj.version>3.11.0</assertj.version>
<coveralls-maven-plugin.version>4.3.0</coveralls-maven-plugin.version> <coveralls-maven-plugin.version>4.3.0</coveralls-maven-plugin.version>
@ -19,15 +23,6 @@
<lombok.version>1.18.2</lombok.version> <lombok.version>1.18.2</lombok.version>
</properties> </properties>
<parent>
<groupId>net.kemitix</groupId>
<artifactId>kemitix-parent</artifactId>
<version>5.1.1</version>
<relativePath/>
</parent>
<artifactId>conditional</artifactId>
<version>DEV-SNAPSHOT</version>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.projectlombok</groupId> <groupId>org.projectlombok</groupId>

View file

@ -45,18 +45,6 @@ public interface Condition {
return FalseCondition.FALSE; return FalseCondition.FALSE;
} }
/**
* Create a new {@code Condition} for the boolean opposite of the clause.
*
* @param clause the condition to test
* @return the Condition
* @deprecated use {@link #not()}
*/
@Deprecated
static Condition whereNot(final boolean clause) {
return where(clause).not();
}
/** /**
* Checks if the Condition is true or not. * Checks if the Condition is true or not.
* *
@ -98,18 +86,6 @@ public interface Condition {
return Condition.where(isTrue()).and(other::isTrue); return Condition.where(isTrue()).and(other::isTrue);
} }
/**
* Logically AND combine the current {@code Condition} with boolean opposite of the clause.
*
* @param clause the condition to test
* @return the Condition
* @deprecated use {@link #not()}
*/
@Deprecated
default Condition andNot(final Supplier<Boolean> clause) {
return and(clause).not();
}
/** /**
* Logically OR combine the current {@code Condition} with the clause. * Logically OR combine the current {@code Condition} with the clause.
* *
@ -129,18 +105,6 @@ public interface Condition {
return where(isTrue()).or(other::isTrue); return where(isTrue()).or(other::isTrue);
} }
/**
* Logically OR combine the current {@code Condition} with the boolean opposite of the clause.
*
* @param clause the condition to test
* @return the Condition
* @deprecated use {@link #not()}
*/
@Deprecated
default Condition orNot(final Supplier<Boolean> clause) {
return or(clause).not();
}
/** /**
* Perform this response if the {@code Condition} is {@code true}. * Perform this response if the {@code Condition} is {@code true}.
* *

View file

@ -124,19 +124,6 @@ public interface Value {
return Value.where(clause.isTrue()); return Value.where(clause.isTrue());
} }
/**
* Create a new {@link ValueClause} for the boolean opposite of the clause.
*
* @param clause the condition to test
* @param <T> the type of the value
* @return a true or false value clause
* @deprecated use {@link #where(boolean)}.{@link ValueClause#not()}
*/
@Deprecated
static <T> ValueClause<T> whereNot(final boolean clause) {
return Value.<T>where(clause).not();
}
/** /**
* An intermediate state in determining the final {@link Value}. * An intermediate state in determining the final {@link Value}.
* *

View file

@ -121,7 +121,7 @@ public class ConditionalTest implements WithAssertions {
@Test @Test
public void whereNotFalseThenRuns() { public void whereNotFalseThenRuns() {
//when //when
Condition.whereNot(false) Condition.where(false).not()
.then(thenResponse); .then(thenResponse);
//then //then
assertThatTheThenResponseRuns(); assertThatTheThenResponseRuns();
@ -130,7 +130,7 @@ public class ConditionalTest implements WithAssertions {
@Test @Test
public void whereNotTrueThenOtherwiseRuns() { public void whereNotTrueThenOtherwiseRuns() {
//when //when
Condition.whereNot(true) Condition.where(true).not()
.then(thenResponse) .then(thenResponse)
.otherwise(otherwiseResponse); .otherwise(otherwiseResponse);
//then //then
@ -141,7 +141,7 @@ public class ConditionalTest implements WithAssertions {
public void whereTrueAndNotFalseThenRuns() { public void whereTrueAndNotFalseThenRuns() {
//when //when
Condition.where(true) Condition.where(true)
.andNot(() -> false) .and(() -> false).not()
.then(thenResponse); .then(thenResponse);
//then //then
assertThatTheThenResponseRuns(); assertThatTheThenResponseRuns();
@ -151,7 +151,7 @@ public class ConditionalTest implements WithAssertions {
public void whereTrueAndNotTrueThenOtherwiseRuns() { public void whereTrueAndNotTrueThenOtherwiseRuns() {
//when //when
Condition.where(true) Condition.where(true)
.andNot(() -> true) .and(() -> true).not()
.then(thenResponse) .then(thenResponse)
.otherwise(otherwiseResponse); .otherwise(otherwiseResponse);
//then //then
@ -162,7 +162,7 @@ public class ConditionalTest implements WithAssertions {
public void whereFalseOrNotFalseThenRuns() { public void whereFalseOrNotFalseThenRuns() {
//when //when
Condition.where(false) Condition.where(false)
.orNot(() -> false) .or(() -> false).not()
.then(thenResponse); .then(thenResponse);
//then //then
assertThatTheThenResponseRuns(); assertThatTheThenResponseRuns();
@ -172,7 +172,7 @@ public class ConditionalTest implements WithAssertions {
public void whereFalseOrNotTrueThenOtherwiseRuns() { public void whereFalseOrNotTrueThenOtherwiseRuns() {
//when //when
Condition.where(false) Condition.where(false)
.orNot(() -> true) .or(() -> true).not()
.then(thenResponse) .then(thenResponse)
.otherwise(otherwiseResponse); .otherwise(otherwiseResponse);
//then //then

View file

@ -53,7 +53,7 @@ public class ValueTest implements WithAssertions {
@Test @Test
public void valueWhereClauseIsTrue() { public void valueWhereClauseIsTrue() {
//when //when
val result = Value.<String>where(TRUE_CONDITION).then(() -> TRUE) final val result = Value.<String>where(TRUE_CONDITION).then(() -> TRUE)
.otherwise(() -> FALSE); .otherwise(() -> FALSE);
//then //then
assertThat(result).isEqualTo(TRUE); assertThat(result).isEqualTo(TRUE);
@ -62,7 +62,7 @@ public class ValueTest implements WithAssertions {
@Test @Test
public void valueWhereClauseIsFalse() { public void valueWhereClauseIsFalse() {
//when //when
val result = Value.<String>where(FALSE_CONDITION).then(() -> TRUE) final val result = Value.<String>where(FALSE_CONDITION).then(() -> TRUE)
.otherwise(() -> FALSE); .otherwise(() -> FALSE);
//then //then
assertThat(result).isEqualTo(FALSE); assertThat(result).isEqualTo(FALSE);
@ -71,7 +71,7 @@ public class ValueTest implements WithAssertions {
@Test @Test
public void valueWhereTrueAndTrueIsTrue() { public void valueWhereTrueAndTrueIsTrue() {
//when //when
val result = Value.<String>where(TRUE_CONDITION).and(() -> true) final val result = Value.<String>where(TRUE_CONDITION).and(() -> true)
.then(() -> TRUE) .then(() -> TRUE)
.otherwise(() -> FALSE); .otherwise(() -> FALSE);
//then //then
@ -81,7 +81,7 @@ public class ValueTest implements WithAssertions {
@Test @Test
public void valueWhereTrueAndFalseIsFalse() { public void valueWhereTrueAndFalseIsFalse() {
//when //when
val result = Value.<String>where(TRUE_CONDITION).and(() -> false) final val result = Value.<String>where(TRUE_CONDITION).and(() -> false)
.then(() -> TRUE) .then(() -> TRUE)
.otherwise(() -> FALSE); .otherwise(() -> FALSE);
//then //then
@ -91,7 +91,7 @@ public class ValueTest implements WithAssertions {
@Test @Test
public void valueWhereFalseAndTrueIsFalse() { public void valueWhereFalseAndTrueIsFalse() {
//when //when
val result = Value.<String>where(FALSE_CONDITION).and(() -> true) final val result = Value.<String>where(FALSE_CONDITION).and(() -> true)
.then(() -> TRUE) .then(() -> TRUE)
.otherwise(() -> FALSE); .otherwise(() -> FALSE);
//then //then
@ -101,7 +101,7 @@ public class ValueTest implements WithAssertions {
@Test @Test
public void valueWhereFalseAndFalseIsFalse() { public void valueWhereFalseAndFalseIsFalse() {
//when //when
val result = Value.<String>where(FALSE_CONDITION).and(() -> false) final val result = Value.<String>where(FALSE_CONDITION).and(() -> false)
.then(() -> TRUE) .then(() -> TRUE)
.otherwise(() -> FALSE); .otherwise(() -> FALSE);
//then //then
@ -111,7 +111,7 @@ public class ValueTest implements WithAssertions {
@Test @Test
public void valueWhereTrueOrTrueIsTrue() { public void valueWhereTrueOrTrueIsTrue() {
//when //when
val result = Value.<String>where(TRUE_CONDITION).or(() -> true) final val result = Value.<String>where(TRUE_CONDITION).or(() -> true)
.then(() -> TRUE) .then(() -> TRUE)
.otherwise(() -> FALSE); .otherwise(() -> FALSE);
//then //then
@ -121,7 +121,7 @@ public class ValueTest implements WithAssertions {
@Test @Test
public void valueWhereTrueOrFalseIsTrue() { public void valueWhereTrueOrFalseIsTrue() {
//when //when
val result = Value.<String>where(TRUE_CONDITION).or(() -> false) final val result = Value.<String>where(TRUE_CONDITION).or(() -> false)
.then(() -> TRUE) .then(() -> TRUE)
.otherwise(() -> FALSE); .otherwise(() -> FALSE);
//then //then
@ -131,7 +131,7 @@ public class ValueTest implements WithAssertions {
@Test @Test
public void valueWhereFalseOrTrueIsTrue() { public void valueWhereFalseOrTrueIsTrue() {
//when //when
val result = Value.<String>where(FALSE_CONDITION).or(() -> true) final val result = Value.<String>where(FALSE_CONDITION).or(() -> true)
.then(() -> TRUE) .then(() -> TRUE)
.otherwise(() -> FALSE); .otherwise(() -> FALSE);
//then //then
@ -141,7 +141,7 @@ public class ValueTest implements WithAssertions {
@Test @Test
public void valueWhereFalseOrFalseIsFalse() { public void valueWhereFalseOrFalseIsFalse() {
//when //when
val result = Value.<String>where(FALSE_CONDITION).or(() -> false) final val result = Value.<String>where(FALSE_CONDITION).or(() -> false)
.then(() -> TRUE) .then(() -> TRUE)
.otherwise(() -> FALSE); .otherwise(() -> FALSE);
//then //then
@ -151,7 +151,7 @@ public class ValueTest implements WithAssertions {
@Test @Test
public void valueWhereNotTrueIsFalse() { public void valueWhereNotTrueIsFalse() {
//when //when
val result = Value.<String>whereNot(true).then(() -> TRUE) final val result = Value.<String>where(true).not().then(() -> TRUE)
.otherwise(() -> FALSE); .otherwise(() -> FALSE);
//then //then
assertThat(result).isEqualTo(FALSE); assertThat(result).isEqualTo(FALSE);
@ -160,7 +160,7 @@ public class ValueTest implements WithAssertions {
@Test @Test
public void deprecatedValueWhereNotFalseIsTrue() { public void deprecatedValueWhereNotFalseIsTrue() {
//when //when
val result = Value.<String>whereNot(false).then(() -> TRUE) final val result = Value.<String>where(false).not().then(() -> TRUE)
.otherwise(() -> FALSE); .otherwise(() -> FALSE);
//then //then
assertThat(result).isEqualTo(TRUE); assertThat(result).isEqualTo(TRUE);
@ -169,7 +169,7 @@ public class ValueTest implements WithAssertions {
@Test @Test
public void valueWhereNotFalseIsTrue() { public void valueWhereNotFalseIsTrue() {
//when //when
val result = Value.<String>where(false).not().then(() -> TRUE) final val result = Value.<String>where(false).not().then(() -> TRUE)
.otherwise(() -> FALSE); .otherwise(() -> FALSE);
//then //then
assertThat(result).isEqualTo(TRUE); assertThat(result).isEqualTo(TRUE);
@ -178,7 +178,7 @@ public class ValueTest implements WithAssertions {
@Test @Test
public void valueWhereTrueAndNotTrueIsFalse() { public void valueWhereTrueAndNotTrueIsFalse() {
//when //when
val result = Value.<String>where(TRUE_CONDITION).andNot(() -> true) final val result = Value.<String>where(TRUE_CONDITION).and(() -> true).not()
.then(() -> TRUE) .then(() -> TRUE)
.otherwise(() -> FALSE); .otherwise(() -> FALSE);
//then //then
@ -188,7 +188,7 @@ public class ValueTest implements WithAssertions {
@Test @Test
public void valueWhereTrueAndNotFalseIsTrue() { public void valueWhereTrueAndNotFalseIsTrue() {
//when //when
val result = Value.<String>where(TRUE_CONDITION).andNot(() -> false) final val result = Value.<String>where(TRUE_CONDITION).and(() -> false).not()
.then(() -> TRUE) .then(() -> TRUE)
.otherwise(() -> FALSE); .otherwise(() -> FALSE);
//then //then
@ -198,7 +198,7 @@ public class ValueTest implements WithAssertions {
@Test @Test
public void valueWhereFalseAndNotTrueIsFalse() { public void valueWhereFalseAndNotTrueIsFalse() {
//when //when
val result = Value.<String>where(FALSE_CONDITION).and(() -> true) final val result = Value.<String>where(FALSE_CONDITION).and(() -> true)
.then(() -> TRUE) .then(() -> TRUE)
.otherwise(() -> FALSE); .otherwise(() -> FALSE);
//then //then
@ -208,7 +208,7 @@ public class ValueTest implements WithAssertions {
@Test @Test
public void valueWhereFalseAndNotFalseIsFalse() { public void valueWhereFalseAndNotFalseIsFalse() {
//when //when
val result = Value.<String>where(FALSE_CONDITION).and(() -> false) final val result = Value.<String>where(FALSE_CONDITION).and(() -> false)
.then(() -> TRUE) .then(() -> TRUE)
.otherwise(() -> FALSE); .otherwise(() -> FALSE);
//then //then
@ -218,7 +218,7 @@ public class ValueTest implements WithAssertions {
@Test @Test
public void valueWhereTrueOrNotTrueIsTrue() { public void valueWhereTrueOrNotTrueIsTrue() {
//when //when
val result = Value.<String>where(true).orNot(() -> true) final val result = Value.<String>where(true).orNot(() -> true)
.then(() -> TRUE) .then(() -> TRUE)
.otherwise(() -> FALSE); .otherwise(() -> FALSE);
//then //then
@ -228,7 +228,7 @@ public class ValueTest implements WithAssertions {
@Test @Test
public void valueWhereTrueOrNotFalseIsTrue() { public void valueWhereTrueOrNotFalseIsTrue() {
//when //when
val result = Value.<String>where(TRUE_CONDITION).orNot(() -> false) final val result = Value.<String>where(TRUE_CONDITION).orNot(() -> false)
.then(() -> TRUE) .then(() -> TRUE)
.otherwise(() -> FALSE); .otherwise(() -> FALSE);
//then //then
@ -238,7 +238,7 @@ public class ValueTest implements WithAssertions {
@Test @Test
public void deprecatedValueWhereFalseOrNotTrueIsFalse() { public void deprecatedValueWhereFalseOrNotTrueIsFalse() {
//when //when
val result = Value.<String>where(FALSE_CONDITION).orNot(() -> true) final val result = Value.<String>where(FALSE_CONDITION).orNot(() -> true)
.then(() -> TRUE) .then(() -> TRUE)
.otherwise(() -> FALSE); .otherwise(() -> FALSE);
//then //then
@ -248,7 +248,7 @@ public class ValueTest implements WithAssertions {
@Test @Test
public void valueWhereFalseOrNotTrueIsFalse() { public void valueWhereFalseOrNotTrueIsFalse() {
//when //when
val result = Value.<String>where(FALSE_CONDITION).or(() -> true).not() final val result = Value.<String>where(FALSE_CONDITION).or(() -> true).not()
.then(() -> TRUE) .then(() -> TRUE)
.otherwise(() -> FALSE); .otherwise(() -> FALSE);
//then //then
@ -258,7 +258,7 @@ public class ValueTest implements WithAssertions {
@Test @Test
public void valueWhereFalseOrNotFalseIsTrue() { public void valueWhereFalseOrNotFalseIsTrue() {
//when //when
val result = Value.<String>where(false).orNot(() -> false) final val result = Value.<String>where(false).orNot(() -> false)
.then(() -> TRUE) .then(() -> TRUE)
.otherwise(() -> FALSE); .otherwise(() -> FALSE);
//then //then
@ -308,4 +308,13 @@ public class ValueTest implements WithAssertions {
assertThat(result).isEmpty(); assertThat(result).isEmpty();
assertThat(atomicInteger).hasValue(0); assertThat(atomicInteger).hasValue(0);
} }
@Test
public void deprecatedAndNot() {
//when
final String result = Value.<String>where(TRUE_CONDITION).andNot(() -> false)
.then(() -> TRUE).otherwise(() -> FALSE);
//then
assertThat(result).isSameAs(TRUE);
}
} }