Skip to content

Commit

Permalink
Merge branch 'master' of github.com:yegor256/cactoos
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Jun 19, 2017
2 parents 10521db + b75f9bf commit 534825d
Show file tree
Hide file tree
Showing 6 changed files with 292 additions and 0 deletions.
43 changes: 43 additions & 0 deletions src/main/java/org/cactoos/func/False.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* The MIT License (MIT)
*
* Copyright (c) 2017 Yegor Bugayenko
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.cactoos.func;

import org.cactoos.Scalar;

/**
* Logical false.
*
* <p>There is no thread-safety guarantee.
*
* @author Vseslav Sekorin (vssekorin@gmail.com)
* @version $Id$
* @since 0.7
*/
public final class False implements Scalar<Boolean> {

@Override
public Boolean asValue() throws Exception {
return false;
}
}
56 changes: 56 additions & 0 deletions src/main/java/org/cactoos/func/Neg.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/**
* The MIT License (MIT)
*
* Copyright (c) 2017 Yegor Bugayenko
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.cactoos.func;

import org.cactoos.Scalar;

/**
* Negative.
*
* <p>There is no thread-safety guarantee.
*
* @author Vseslav Sekorin (vssekorin@gmail.com)
* @version $Id$
* @since 0.7
*/
public final class Neg implements Scalar<Boolean> {

/**
* The origin scalar.
*/
private final Scalar<Boolean> origin;

/**
* Ctor.
* @param origin The scalar
*/
public Neg(final Scalar<Boolean> origin) {
this.origin = origin;
}

@Override
public Boolean asValue() throws Exception {
return !this.origin.asValue();
}
}
43 changes: 43 additions & 0 deletions src/main/java/org/cactoos/func/True.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* The MIT License (MIT)
*
* Copyright (c) 2017 Yegor Bugayenko
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.cactoos.func;

import org.cactoos.Scalar;

/**
* Logical truth.
*
* <p>There is no thread-safety guarantee.
*
* @author Vseslav Sekorin (vssekorin@gmail.com)
* @version $Id$
* @since 0.7
*/
public final class True implements Scalar<Boolean> {

@Override
public Boolean asValue() throws Exception {
return true;
}
}
48 changes: 48 additions & 0 deletions src/test/java/org/cactoos/func/FalseTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/**
* The MIT License (MIT)
*
* Copyright (c) 2017 Yegor Bugayenko
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.cactoos.func;

import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.Test;

/**
* Test case for {@link False}.
*
* @author Vseslav Sekorin (vssekorin@gmail.com)
* @version $Id$
* @since 0.7
* @checkstyle JavadocMethodCheck (500 lines)
*/
public final class FalseTest {

@Test
public void asValue() throws Exception {
MatcherAssert.assertThat(
new False().asValue(),
Matchers.equalTo(false)
);
}

}
55 changes: 55 additions & 0 deletions src/test/java/org/cactoos/func/NegTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/**
* The MIT License (MIT)
*
* Copyright (c) 2017 Yegor Bugayenko
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.cactoos.func;

import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.Test;

/**
* Test case for {@link Neg}.
*
* @author Vseslav Sekorin (vssekorin@gmail.com)
* @version $Id$
* @since 0.7
* @checkstyle JavadocMethodCheck (500 lines)
*/
public final class NegTest {

@Test
public void trueToFalse() throws Exception {
MatcherAssert.assertThat(
new Neg(new True()).asValue(),
Matchers.equalTo(new False().asValue())
);
}

@Test
public void falseToTrue() throws Exception {
MatcherAssert.assertThat(
new Neg(new False()).asValue(),
Matchers.equalTo(new True().asValue())
);
}
}
47 changes: 47 additions & 0 deletions src/test/java/org/cactoos/func/TrueTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/**
* The MIT License (MIT)
*
* Copyright (c) 2017 Yegor Bugayenko
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.cactoos.func;

import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.Test;

/**
* Test case for {@link True}.
*
* @author Vseslav Sekorin (vssekorin@gmail.com)
* @version $Id$
* @since 0.7
* @checkstyle JavadocMethodCheck (500 lines)
*/
public final class TrueTest {

@Test
public void asValue() throws Exception {
MatcherAssert.assertThat(
new True().asValue(),
Matchers.equalTo(true)
);
}
}

0 comments on commit 534825d

Please sign in to comment.