Skip to content

Commit

Permalink
Merge branch '__rultor'
Browse files Browse the repository at this point in the history
  • Loading branch information
rultor committed Jun 2, 2017
2 parents 3c02942 + a21ee42 commit f5136d0
Show file tree
Hide file tree
Showing 11 changed files with 602 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,10 @@ mvn clean install -Pqulice
Note: [Checkstyle](https://en.wikipedia.org/wiki/Checkstyle) is used as a static code analyze tool with
[checks list](http://checkstyle.sourceforge.net/checks.html) in GitHub precommits.

## Contributors

- [Kirill Che.](https://github.com/g4s8) [email protected]

## License (MIT)

Copyright (c) 2017 Yegor Bugayenko
Expand Down
68 changes: 68 additions & 0 deletions src/main/java/org/cactoos/text/TextAsBool.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/**
* 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.text;

import java.io.IOException;
import org.cactoos.Scalar;
import org.cactoos.Text;

/**
* Text as {@link Boolean}.
*
* <p>There is no thread-safety guarantee.
*
* @author Kirill ([email protected])
* @version $Id$
* @since 0.2
*/
public final class TextAsBool implements Scalar<Boolean> {

/**
* Source text.
*/
private final Text text;

/**
* Ctor.
*
* @param string True or false string
*/
public TextAsBool(final String string) {
this(new StringAsText(string));
}

/**
* Ctor.
*
* @param text True or false text
*/
public TextAsBool(final Text text) {
this.text = text;
}

@Override
public Boolean asValue() throws IOException {
return Boolean.valueOf(this.text.asString());
}
}
68 changes: 68 additions & 0 deletions src/main/java/org/cactoos/text/TextAsDouble.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/**
* 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.text;

import java.io.IOException;
import org.cactoos.Scalar;
import org.cactoos.Text;

/**
* Text as {@link Double}.
*
* <p>There is no thread-safety guarantee.
*
* @author Kirill ([email protected])
* @version $Id$
* @since 0.2
*/
public final class TextAsDouble implements Scalar<Double> {

/**
* Source text.
*/
private final Text text;

/**
* Ctor.
*
* @param string Number-string
*/
public TextAsDouble(final String string) {
this(new StringAsText(string));
}

/**
* Ctor.
*
* @param text Number-text
*/
public TextAsDouble(final Text text) {
this.text = text;
}

@Override
public Double asValue() throws IOException {
return Double.valueOf(this.text.asString());
}
}
68 changes: 68 additions & 0 deletions src/main/java/org/cactoos/text/TextAsFloat.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/**
* 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.text;

import java.io.IOException;
import org.cactoos.Scalar;
import org.cactoos.Text;

/**
* Text as {@link Float}.
*
* <p>There is no thread-safety guarantee.
*
* @author Kirill ([email protected])
* @version $Id$
* @since 0.2
*/
public final class TextAsFloat implements Scalar<Float> {

/**
* Source text.
*/
private final Text text;

/**
* Ctor.
*
* @param string Number-string
*/
public TextAsFloat(final String string) {
this(new StringAsText(string));
}

/**
* Ctor.
*
* @param text Number-text
*/
public TextAsFloat(final Text text) {
this.text = text;
}

@Override
public Float asValue() throws IOException {
return Float.valueOf(this.text.asString());
}
}
68 changes: 68 additions & 0 deletions src/main/java/org/cactoos/text/TextAsInt.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/**
* 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.text;

import java.io.IOException;
import org.cactoos.Scalar;
import org.cactoos.Text;

/**
* Text as {@link Integer}.
*
* <p>There is no thread-safety guarantee.
*
* @author Kirill ([email protected])
* @version $Id$
* @since 0.2
*/
public final class TextAsInt implements Scalar<Integer> {

/**
* Source text.
*/
private final Text text;

/**
* Ctor.
*
* @param string Number-string
*/
public TextAsInt(final String string) {
this(new StringAsText(string));
}

/**
* Ctor.
*
* @param text Number-text
*/
public TextAsInt(final Text text) {
this.text = text;
}

@Override
public Integer asValue() throws IOException {
return Integer.valueOf(this.text.asString());
}
}
68 changes: 68 additions & 0 deletions src/main/java/org/cactoos/text/TextAsLong.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/**
* 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.text;

import java.io.IOException;
import org.cactoos.Scalar;
import org.cactoos.Text;

/**
* Text as {@link Long}.
*
* <p>There is no thread-safety guarantee.
*
* @author Kirill ([email protected])
* @version $Id$
* @since 0.2
*/
public final class TextAsLong implements Scalar<Long> {

/**
* Source text.
*/
private final Text text;

/**
* Ctor.
*
* @param string Number-string
*/
public TextAsLong(final String string) {
this(new StringAsText(string));
}

/**
* Ctor.
*
* @param text Number-text
*/
public TextAsLong(final Text text) {
this.text = text;
}

@Override
public Long asValue() throws IOException {
return Long.valueOf(this.text.asString());
}
}
Loading

0 comments on commit f5136d0

Please sign in to comment.