diff --git a/.gitignore b/rome-utils/.gitignore similarity index 100% rename from .gitignore rename to rome-utils/.gitignore diff --git a/LICENSE b/rome-utils/LICENSE similarity index 100% rename from LICENSE rename to rome-utils/LICENSE diff --git a/README.md b/rome-utils/README.md similarity index 100% rename from README.md rename to rome-utils/README.md diff --git a/pom.xml b/rome-utils/pom.xml similarity index 100% rename from pom.xml rename to rome-utils/pom.xml diff --git a/src/main/java/com/rometools/utils/Alternatives.java b/rome-utils/src/main/java/com/rometools/utils/Alternatives.java similarity index 96% rename from src/main/java/com/rometools/utils/Alternatives.java rename to rome-utils/src/main/java/com/rometools/utils/Alternatives.java index 8baea38..ab0abd8 100644 --- a/src/main/java/com/rometools/utils/Alternatives.java +++ b/rome-utils/src/main/java/com/rometools/utils/Alternatives.java @@ -1,37 +1,37 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.rometools.utils; - -public final class Alternatives { - - private Alternatives() { - } - - /** - * Returns the first object that is not null - * - * @param objects The objects to process - * @return The first value that is not null. null when there is no not-null value - */ - public static T firstNotNull(final T... objects) { - for (final T object : objects) { - if (object != null) { - return object; - } - } - return null; - } - -} +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.rometools.utils; + +public final class Alternatives { + + private Alternatives() { + } + + /** + * Returns the first object that is not null + * + * @param objects The objects to process + * @return The first value that is not null. null when there is no not-null value + */ + public static T firstNotNull(final T... objects) { + for (final T object : objects) { + if (object != null) { + return object; + } + } + return null; + } + +} diff --git a/src/main/java/com/rometools/utils/Dates.java b/rome-utils/src/main/java/com/rometools/utils/Dates.java similarity index 96% rename from src/main/java/com/rometools/utils/Dates.java rename to rome-utils/src/main/java/com/rometools/utils/Dates.java index c1149f7..a1c2f95 100644 --- a/src/main/java/com/rometools/utils/Dates.java +++ b/rome-utils/src/main/java/com/rometools/utils/Dates.java @@ -1,38 +1,38 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.rometools.utils; - -import java.util.Date; - -public final class Dates { - - private Dates() { - } - - /** - * Creates a copy on a Date. - * - * @param d The Date to copy, can be null - * @return null when the input Date was null, a copy of the Date otherwise - */ - public static Date copy(final Date d) { - if (d == null) { - return null; - } else { - return new Date(d.getTime()); - } - } - -} +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.rometools.utils; + +import java.util.Date; + +public final class Dates { + + private Dates() { + } + + /** + * Creates a copy on a Date. + * + * @param d The Date to copy, can be null + * @return null when the input Date was null, a copy of the Date otherwise + */ + public static Date copy(final Date d) { + if (d == null) { + return null; + } else { + return new Date(d.getTime()); + } + } + +} diff --git a/src/main/java/com/rometools/utils/Doubles.java b/rome-utils/src/main/java/com/rometools/utils/Doubles.java similarity index 96% rename from src/main/java/com/rometools/utils/Doubles.java rename to rome-utils/src/main/java/com/rometools/utils/Doubles.java index 7f4f8fd..96fecac 100644 --- a/src/main/java/com/rometools/utils/Doubles.java +++ b/rome-utils/src/main/java/com/rometools/utils/Doubles.java @@ -1,39 +1,39 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.rometools.utils; - -public class Doubles { - - private Doubles() { - } - - /** - * Converts a String into an Double. - * - * @param s The String to convert, may be null - * @return The parsed Double or null when parsing is not possible - */ - public static Double parse(final String s) { - Double parsed = null; - try { - if (s != null) { - parsed = Double.parseDouble(s); - } - } catch (final NumberFormatException e) { - } - return parsed; - } - -} +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.rometools.utils; + +public class Doubles { + + private Doubles() { + } + + /** + * Converts a String into an Double. + * + * @param s The String to convert, may be null + * @return The parsed Double or null when parsing is not possible + */ + public static Double parse(final String s) { + Double parsed = null; + try { + if (s != null) { + parsed = Double.parseDouble(s); + } + } catch (final NumberFormatException e) { + } + return parsed; + } + +} diff --git a/src/main/java/com/rometools/utils/IO.java b/rome-utils/src/main/java/com/rometools/utils/IO.java similarity index 100% rename from src/main/java/com/rometools/utils/IO.java rename to rome-utils/src/main/java/com/rometools/utils/IO.java diff --git a/src/main/java/com/rometools/utils/Integers.java b/rome-utils/src/main/java/com/rometools/utils/Integers.java similarity index 96% rename from src/main/java/com/rometools/utils/Integers.java rename to rome-utils/src/main/java/com/rometools/utils/Integers.java index 8694fdf..4314a36 100644 --- a/src/main/java/com/rometools/utils/Integers.java +++ b/rome-utils/src/main/java/com/rometools/utils/Integers.java @@ -1,36 +1,36 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.rometools.utils; - -public final class Integers { - - private Integers() { - } - - /** - * Converts a String into an Integer. - * - * @param s The String to convert, may be null - * @return The parsed Integer or null when parsing is not possible - */ - public static Integer parse(final String s) { - try { - return Integer.parseInt(s); - } catch (final NumberFormatException e) { - return null; - } - } - -} +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.rometools.utils; + +public final class Integers { + + private Integers() { + } + + /** + * Converts a String into an Integer. + * + * @param s The String to convert, may be null + * @return The parsed Integer or null when parsing is not possible + */ + public static Integer parse(final String s) { + try { + return Integer.parseInt(s); + } catch (final NumberFormatException e) { + return null; + } + } + +} diff --git a/src/main/java/com/rometools/utils/Lists.java b/rome-utils/src/main/java/com/rometools/utils/Lists.java similarity index 96% rename from src/main/java/com/rometools/utils/Lists.java rename to rome-utils/src/main/java/com/rometools/utils/Lists.java index 5beff55..be6186c 100644 --- a/src/main/java/com/rometools/utils/Lists.java +++ b/rome-utils/src/main/java/com/rometools/utils/Lists.java @@ -1,116 +1,116 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.rometools.utils; - -import java.util.ArrayList; -import java.util.List; - -public final class Lists { - - private Lists() { - } - - /** - * Returns the list when it is not null. Returns a new list otherwise. - * - * @param list The list to process, can be null - * @return The input list when it is not null, a new list otherwise - */ - public static List createWhenNull(final List list) { - if (list == null) { - return new ArrayList(); - } else { - return list; - } - } - - /** - * Creates a new List with the given item as the first entry. - * - * @param item The item to add to the new list - * @return List containing the given item - */ - public static List create(final T item) { - final List list = new ArrayList(); - list.add(item); - return list; - } - - /** - * Extracts the first entry of the list when it is not null and contains values. - * - * @param list The list to extract the first entry from, can be null - * @return The first entry of the list when it is not null or empty, null otherwise - */ - public static T firstEntry(final List list) { - if (list != null && !list.isEmpty()) { - return list.get(0); - } else { - return null; - } - } - - /** - * Checks whether the list is null or empty. - * - * @param list The list to check - * @return true when the list is null or empty, false otherwise - */ - public static boolean isEmpty(final List list) { - return list == null || list.isEmpty(); - } - - /** - * Checks whether the list is not null and not empty. - * - * @param list The list to check - * @return true when the list is not null and not empty - */ - public static boolean isNotEmpty(final List list) { - return !isEmpty(list); - } - - /** - * Checks whether the list has the given size. A null list is treated like a list without - * entries. - * - * @param list The list to check - * @param size The size to check - * @return true when the list has the given size or when size = 0 and the list is null, false - * otherwise - */ - public static boolean sizeIs(final List list, final int size) { - if (size == 0) { - return list == null || list.isEmpty(); - } else { - return list != null && list.size() == size; - } - } - - /** - * Returns null, when the given list is empty or null - * - * @param list The list to process - * @return null when the list is empty or null, the given list otherwise - */ - public static List emptyToNull(final List list) { - if (isEmpty(list)) { - return null; - } else { - return list; - } - } - -} +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.rometools.utils; + +import java.util.ArrayList; +import java.util.List; + +public final class Lists { + + private Lists() { + } + + /** + * Returns the list when it is not null. Returns a new list otherwise. + * + * @param list The list to process, can be null + * @return The input list when it is not null, a new list otherwise + */ + public static List createWhenNull(final List list) { + if (list == null) { + return new ArrayList(); + } else { + return list; + } + } + + /** + * Creates a new List with the given item as the first entry. + * + * @param item The item to add to the new list + * @return List containing the given item + */ + public static List create(final T item) { + final List list = new ArrayList(); + list.add(item); + return list; + } + + /** + * Extracts the first entry of the list when it is not null and contains values. + * + * @param list The list to extract the first entry from, can be null + * @return The first entry of the list when it is not null or empty, null otherwise + */ + public static T firstEntry(final List list) { + if (list != null && !list.isEmpty()) { + return list.get(0); + } else { + return null; + } + } + + /** + * Checks whether the list is null or empty. + * + * @param list The list to check + * @return true when the list is null or empty, false otherwise + */ + public static boolean isEmpty(final List list) { + return list == null || list.isEmpty(); + } + + /** + * Checks whether the list is not null and not empty. + * + * @param list The list to check + * @return true when the list is not null and not empty + */ + public static boolean isNotEmpty(final List list) { + return !isEmpty(list); + } + + /** + * Checks whether the list has the given size. A null list is treated like a list without + * entries. + * + * @param list The list to check + * @param size The size to check + * @return true when the list has the given size or when size = 0 and the list is null, false + * otherwise + */ + public static boolean sizeIs(final List list, final int size) { + if (size == 0) { + return list == null || list.isEmpty(); + } else { + return list != null && list.size() == size; + } + } + + /** + * Returns null, when the given list is empty or null + * + * @param list The list to process + * @return null when the list is empty or null, the given list otherwise + */ + public static List emptyToNull(final List list) { + if (isEmpty(list)) { + return null; + } else { + return list; + } + } + +} diff --git a/src/main/java/com/rometools/utils/Longs.java b/rome-utils/src/main/java/com/rometools/utils/Longs.java similarity index 96% rename from src/main/java/com/rometools/utils/Longs.java rename to rome-utils/src/main/java/com/rometools/utils/Longs.java index 023e1cf..e3e55d1 100644 --- a/src/main/java/com/rometools/utils/Longs.java +++ b/rome-utils/src/main/java/com/rometools/utils/Longs.java @@ -1,39 +1,39 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.rometools.utils; - -public final class Longs { - - private Longs() { - } - - /** - * Converts a String into a Long by first parsing it as Double and then casting it to Long. - * - * @param s The String to convert, may be null or in decimal format - * @return The parsed Long or null when parsing is not possible - */ - public static Long parseDecimal(final String s) { - Long parsed = null; - try { - if (s != null) { - parsed = (long) Double.parseDouble(s); - } - } catch (final NumberFormatException e) { - } - return parsed; - } - -} +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.rometools.utils; + +public final class Longs { + + private Longs() { + } + + /** + * Converts a String into a Long by first parsing it as Double and then casting it to Long. + * + * @param s The String to convert, may be null or in decimal format + * @return The parsed Long or null when parsing is not possible + */ + public static Long parseDecimal(final String s) { + Long parsed = null; + try { + if (s != null) { + parsed = (long) Double.parseDouble(s); + } + } catch (final NumberFormatException e) { + } + return parsed; + } + +} diff --git a/src/main/java/com/rometools/utils/Strings.java b/rome-utils/src/main/java/com/rometools/utils/Strings.java similarity index 96% rename from src/main/java/com/rometools/utils/Strings.java rename to rome-utils/src/main/java/com/rometools/utils/Strings.java index 03ab2fd..f8ff575 100644 --- a/src/main/java/com/rometools/utils/Strings.java +++ b/rome-utils/src/main/java/com/rometools/utils/Strings.java @@ -1,126 +1,126 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.rometools.utils; - -import java.util.Locale; - -public final class Strings { - - private Strings() { - } - - /** - * Checks whether a String is null. - * - * @param s The String to check - * @return true when the String is null, false otherwise - */ - public static boolean isNull(final String s) { - return s == null; - } - - /** - * Checks whether a String is null or empty. - * - * @param s The String to check - * @return true when the String is null or empty, false otherwise - */ - public static boolean isEmpty(final String s) { - return isNull(s) || s.isEmpty(); - } - - /** - * Checks whether a String is neither null nor empty. - * - * @param s The String to check - * @return true when the String is neither null nor empty, false otherwise - */ - public static boolean isNotEmpty(final String s) { - return !isEmpty(s); - } - - /** - * Checks whether a String is null, empty or blank. - * - * @param s The String to check - * @return true when the String is null, empty or blank, false otherwise - */ - public static boolean isBlank(final String s) { - return isEmpty(s) || s.trim().isEmpty(); - } - - /** - * Removes the whitespace at the beginning and end of a String. - * - * @param s The String to trim, may be null - * @return null when the input String is null, the trimmed String otherwise - */ - public static String trim(final String s) { - if (s == null) { - return null; - } else { - return s.trim(); - } - } - - /** - * Removes the whitespace at the beginning and end of a String. When the String only contains - * whitespace, it returns null. - * - * @param s The String to trim, may be null - * @return null when the input String is null or does only contain whitespace, the trimmed - * String otherwise - */ - public static String trimToNull(final String s) { - final String trimmed = trim(s); - if (trimmed == null || trimmed.isEmpty()) { - return null; - } else { - return trimmed; - } - } - - /** - * Removes the whitespace at the beginning and end of a String. When the String only contains - * whitespace, it returns null. - * - * @param s The String to trim, may be null - * @return null when the input String is null or does only contain whitespace, the trimmed - * String otherwise - */ - public static String trimToEmpty(final String s) { - final String trimmed = trim(s); - if (trimmed == null || trimmed.isEmpty()) { - return ""; - } else { - return trimmed; - } - } - - /** - * null-safe lower-case conversion of a String. - * - * @param s The String to process, may be null - * @return null when the input String is null, the String in lower-case otherwise - */ - public static String toLowerCase(final String s) { - if (s == null) { - return null; - } else { - return s.toLowerCase(Locale.ENGLISH); - } - } - -} +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.rometools.utils; + +import java.util.Locale; + +public final class Strings { + + private Strings() { + } + + /** + * Checks whether a String is null. + * + * @param s The String to check + * @return true when the String is null, false otherwise + */ + public static boolean isNull(final String s) { + return s == null; + } + + /** + * Checks whether a String is null or empty. + * + * @param s The String to check + * @return true when the String is null or empty, false otherwise + */ + public static boolean isEmpty(final String s) { + return isNull(s) || s.isEmpty(); + } + + /** + * Checks whether a String is neither null nor empty. + * + * @param s The String to check + * @return true when the String is neither null nor empty, false otherwise + */ + public static boolean isNotEmpty(final String s) { + return !isEmpty(s); + } + + /** + * Checks whether a String is null, empty or blank. + * + * @param s The String to check + * @return true when the String is null, empty or blank, false otherwise + */ + public static boolean isBlank(final String s) { + return isEmpty(s) || s.trim().isEmpty(); + } + + /** + * Removes the whitespace at the beginning and end of a String. + * + * @param s The String to trim, may be null + * @return null when the input String is null, the trimmed String otherwise + */ + public static String trim(final String s) { + if (s == null) { + return null; + } else { + return s.trim(); + } + } + + /** + * Removes the whitespace at the beginning and end of a String. When the String only contains + * whitespace, it returns null. + * + * @param s The String to trim, may be null + * @return null when the input String is null or does only contain whitespace, the trimmed + * String otherwise + */ + public static String trimToNull(final String s) { + final String trimmed = trim(s); + if (trimmed == null || trimmed.isEmpty()) { + return null; + } else { + return trimmed; + } + } + + /** + * Removes the whitespace at the beginning and end of a String. When the String only contains + * whitespace, it returns null. + * + * @param s The String to trim, may be null + * @return null when the input String is null or does only contain whitespace, the trimmed + * String otherwise + */ + public static String trimToEmpty(final String s) { + final String trimmed = trim(s); + if (trimmed == null || trimmed.isEmpty()) { + return ""; + } else { + return trimmed; + } + } + + /** + * null-safe lower-case conversion of a String. + * + * @param s The String to process, may be null + * @return null when the input String is null, the String in lower-case otherwise + */ + public static String toLowerCase(final String s) { + if (s == null) { + return null; + } else { + return s.toLowerCase(Locale.ENGLISH); + } + } + +} diff --git a/src/main/resources/.gitignore b/rome-utils/src/main/resources/.gitignore similarity index 100% rename from src/main/resources/.gitignore rename to rome-utils/src/main/resources/.gitignore diff --git a/src/test/java/com/rometools/utils/AlternativesTest.java b/rome-utils/src/test/java/com/rometools/utils/AlternativesTest.java similarity index 97% rename from src/test/java/com/rometools/utils/AlternativesTest.java rename to rome-utils/src/test/java/com/rometools/utils/AlternativesTest.java index 09dc66f..3e3e45d 100644 --- a/src/test/java/com/rometools/utils/AlternativesTest.java +++ b/rome-utils/src/test/java/com/rometools/utils/AlternativesTest.java @@ -1,37 +1,37 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.rometools.utils; - -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.nullValue; -import static org.junit.Assert.assertThat; - -import org.junit.Test; - -public class AlternativesTest { - - @Test - public void testFirstNotNull() { - - final Integer nullInteger = null; - final Integer notNullInteger = 1; - - assertThat(Alternatives.firstNotNull(notNullInteger, nullInteger), is(notNullInteger)); - assertThat(Alternatives.firstNotNull(nullInteger, notNullInteger), is(notNullInteger)); - assertThat(Alternatives.firstNotNull(nullInteger, nullInteger), is(nullValue())); - - } - -} +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.rometools.utils; + +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.nullValue; +import static org.junit.Assert.assertThat; + +import org.junit.Test; + +public class AlternativesTest { + + @Test + public void testFirstNotNull() { + + final Integer nullInteger = null; + final Integer notNullInteger = 1; + + assertThat(Alternatives.firstNotNull(notNullInteger, nullInteger), is(notNullInteger)); + assertThat(Alternatives.firstNotNull(nullInteger, notNullInteger), is(notNullInteger)); + assertThat(Alternatives.firstNotNull(nullInteger, nullInteger), is(nullValue())); + + } + +} diff --git a/src/test/java/com/rometools/utils/DatesTest.java b/rome-utils/src/test/java/com/rometools/utils/DatesTest.java similarity index 96% rename from src/test/java/com/rometools/utils/DatesTest.java rename to rome-utils/src/test/java/com/rometools/utils/DatesTest.java index 5738169..955a965 100644 --- a/src/test/java/com/rometools/utils/DatesTest.java +++ b/rome-utils/src/test/java/com/rometools/utils/DatesTest.java @@ -1,40 +1,40 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.rometools.utils; - -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.notNullValue; -import static org.hamcrest.Matchers.nullValue; -import static org.junit.Assert.assertThat; - -import java.util.Date; - -import org.junit.Test; - -public class DatesTest { - - @Test - public void testCopy() { - - final Date date = new Date(); - final Date nullDate = null; - - assertThat(Dates.copy(date), is(notNullValue())); - assertThat(Dates.copy(date).getTime(), is(date.getTime())); - assertThat(Dates.copy(nullDate), is(nullValue())); - - } - -} +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.rometools.utils; + +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.notNullValue; +import static org.hamcrest.Matchers.nullValue; +import static org.junit.Assert.assertThat; + +import java.util.Date; + +import org.junit.Test; + +public class DatesTest { + + @Test + public void testCopy() { + + final Date date = new Date(); + final Date nullDate = null; + + assertThat(Dates.copy(date), is(notNullValue())); + assertThat(Dates.copy(date).getTime(), is(date.getTime())); + assertThat(Dates.copy(nullDate), is(nullValue())); + + } + +} diff --git a/src/test/java/com/rometools/utils/DoublesTest.java b/rome-utils/src/test/java/com/rometools/utils/DoublesTest.java similarity index 96% rename from src/test/java/com/rometools/utils/DoublesTest.java rename to rome-utils/src/test/java/com/rometools/utils/DoublesTest.java index 342f990..6426cad 100644 --- a/src/test/java/com/rometools/utils/DoublesTest.java +++ b/rome-utils/src/test/java/com/rometools/utils/DoublesTest.java @@ -1,40 +1,40 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.rometools.utils; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.nullValue; - -import org.junit.Test; - -public class DoublesTest { - - @Test - public void testParse() { - - final String nullString = null; - final String emptyString = null; - final String integerString = "1"; - final String decimalString = "1.0"; - - assertThat(Doubles.parse(nullString), is(nullValue())); - assertThat(Doubles.parse(emptyString), is(nullValue())); - assertThat(Doubles.parse(integerString), is(1.0)); - assertThat(Doubles.parse(decimalString), is(1.0)); - - } - -} +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.rometools.utils; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.nullValue; + +import org.junit.Test; + +public class DoublesTest { + + @Test + public void testParse() { + + final String nullString = null; + final String emptyString = null; + final String integerString = "1"; + final String decimalString = "1.0"; + + assertThat(Doubles.parse(nullString), is(nullValue())); + assertThat(Doubles.parse(emptyString), is(nullValue())); + assertThat(Doubles.parse(integerString), is(1.0)); + assertThat(Doubles.parse(decimalString), is(1.0)); + + } + +} diff --git a/src/test/java/com/rometools/utils/IntegersTest.java b/rome-utils/src/test/java/com/rometools/utils/IntegersTest.java similarity index 96% rename from src/test/java/com/rometools/utils/IntegersTest.java rename to rome-utils/src/test/java/com/rometools/utils/IntegersTest.java index 6893b08..f910a4b 100644 --- a/src/test/java/com/rometools/utils/IntegersTest.java +++ b/rome-utils/src/test/java/com/rometools/utils/IntegersTest.java @@ -1,40 +1,40 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.rometools.utils; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.nullValue; - -import org.junit.Test; - -public class IntegersTest { - - @Test - public void testParse() { - - final String nullString = null; - final String emptyString = null; - final String integerString = "1"; - final String decimalString = "1.0"; - - assertThat(Integers.parse(nullString), is(nullValue())); - assertThat(Integers.parse(emptyString), is(nullValue())); - assertThat(Integers.parse(integerString), is(1)); - assertThat(Integers.parse(decimalString), is(nullValue())); - - } - -} +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.rometools.utils; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.nullValue; + +import org.junit.Test; + +public class IntegersTest { + + @Test + public void testParse() { + + final String nullString = null; + final String emptyString = null; + final String integerString = "1"; + final String decimalString = "1.0"; + + assertThat(Integers.parse(nullString), is(nullValue())); + assertThat(Integers.parse(emptyString), is(nullValue())); + assertThat(Integers.parse(integerString), is(1)); + assertThat(Integers.parse(decimalString), is(nullValue())); + + } + +} diff --git a/src/test/java/com/rometools/utils/ListsTest.java b/rome-utils/src/test/java/com/rometools/utils/ListsTest.java similarity index 97% rename from src/test/java/com/rometools/utils/ListsTest.java rename to rome-utils/src/test/java/com/rometools/utils/ListsTest.java index 25e7861..2871cff 100644 --- a/src/test/java/com/rometools/utils/ListsTest.java +++ b/rome-utils/src/test/java/com/rometools/utils/ListsTest.java @@ -1,119 +1,119 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.rometools.utils; - -import static org.hamcrest.Matchers.hasItem; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.notNullValue; -import static org.hamcrest.Matchers.nullValue; -import static org.junit.Assert.assertThat; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.junit.Test; - -public class ListsTest { - - @Test - public void testCreateWhenNull() { - - final List list = new ArrayList(); - final List nullList = null; - - assertThat(Lists.createWhenNull(list), is(notNullValue())); - assertThat(Lists.createWhenNull(list), is(list)); - assertThat(Lists.createWhenNull(nullList), is(notNullValue())); - - } - - @Test - public void testCreate() { - - final List create = Lists.create(1); - assertThat(create, is(notNullValue())); - assertThat(create.size(), is(1)); - assertThat(create, hasItem(1)); - - } - - @Test - public void testFirstEntry() { - - final List nullList = null; - final List listWithoutEntries = new ArrayList(); - final List listWithOneEntry = Arrays.asList(1); - final List listWithTwoEntries = Arrays.asList(1, 2); - - assertThat(Lists.firstEntry(nullList), is(nullValue())); - assertThat(Lists.firstEntry(listWithoutEntries), is(nullValue())); - assertThat(Lists.firstEntry(listWithOneEntry), is(1)); - assertThat(Lists.firstEntry(listWithTwoEntries), is(1)); - - } - - @Test - public void testIsEmpty() { - - final List nullList = null; - final List listWithoutEntries = new ArrayList(); - final List listWithOneEntry = Arrays.asList(1); - - assertThat(Lists.isEmpty(nullList), is(true)); - assertThat(Lists.isEmpty(listWithoutEntries), is(true)); - assertThat(Lists.isEmpty(listWithOneEntry), is(false)); - - } - - @Test - public void testIsNotEmpty() { - - final List nullList = null; - final List listWithoutEntries = new ArrayList(); - final List listWithOneEntry = Arrays.asList(1); - - assertThat(Lists.isNotEmpty(nullList), is(false)); - assertThat(Lists.isNotEmpty(listWithoutEntries), is(false)); - assertThat(Lists.isNotEmpty(listWithOneEntry), is(true)); - } - - @Test - public void testSizeIs() { - - final List nullList = null; - final List listWithoutEntries = new ArrayList(); - final List listWithOneEntry = Arrays.asList(1); - - assertThat(Lists.sizeIs(nullList, 0), is(true)); - assertThat(Lists.sizeIs(listWithoutEntries, 0), is(true)); - assertThat(Lists.sizeIs(listWithOneEntry, 1), is(true)); - - } - - @Test - public void testEmptyToNull() { - - final List nullList = null; - final List listWithoutEntries = new ArrayList(); - final List listWithOneEntry = Arrays.asList(1); - - assertThat(Lists.emptyToNull(nullList), is(nullValue())); - assertThat(Lists.emptyToNull(listWithoutEntries), is(nullValue())); - assertThat(Lists.emptyToNull(listWithOneEntry), is(notNullValue())); - - } - -} +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.rometools.utils; + +import static org.hamcrest.Matchers.hasItem; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.notNullValue; +import static org.hamcrest.Matchers.nullValue; +import static org.junit.Assert.assertThat; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.junit.Test; + +public class ListsTest { + + @Test + public void testCreateWhenNull() { + + final List list = new ArrayList(); + final List nullList = null; + + assertThat(Lists.createWhenNull(list), is(notNullValue())); + assertThat(Lists.createWhenNull(list), is(list)); + assertThat(Lists.createWhenNull(nullList), is(notNullValue())); + + } + + @Test + public void testCreate() { + + final List create = Lists.create(1); + assertThat(create, is(notNullValue())); + assertThat(create.size(), is(1)); + assertThat(create, hasItem(1)); + + } + + @Test + public void testFirstEntry() { + + final List nullList = null; + final List listWithoutEntries = new ArrayList(); + final List listWithOneEntry = Arrays.asList(1); + final List listWithTwoEntries = Arrays.asList(1, 2); + + assertThat(Lists.firstEntry(nullList), is(nullValue())); + assertThat(Lists.firstEntry(listWithoutEntries), is(nullValue())); + assertThat(Lists.firstEntry(listWithOneEntry), is(1)); + assertThat(Lists.firstEntry(listWithTwoEntries), is(1)); + + } + + @Test + public void testIsEmpty() { + + final List nullList = null; + final List listWithoutEntries = new ArrayList(); + final List listWithOneEntry = Arrays.asList(1); + + assertThat(Lists.isEmpty(nullList), is(true)); + assertThat(Lists.isEmpty(listWithoutEntries), is(true)); + assertThat(Lists.isEmpty(listWithOneEntry), is(false)); + + } + + @Test + public void testIsNotEmpty() { + + final List nullList = null; + final List listWithoutEntries = new ArrayList(); + final List listWithOneEntry = Arrays.asList(1); + + assertThat(Lists.isNotEmpty(nullList), is(false)); + assertThat(Lists.isNotEmpty(listWithoutEntries), is(false)); + assertThat(Lists.isNotEmpty(listWithOneEntry), is(true)); + } + + @Test + public void testSizeIs() { + + final List nullList = null; + final List listWithoutEntries = new ArrayList(); + final List listWithOneEntry = Arrays.asList(1); + + assertThat(Lists.sizeIs(nullList, 0), is(true)); + assertThat(Lists.sizeIs(listWithoutEntries, 0), is(true)); + assertThat(Lists.sizeIs(listWithOneEntry, 1), is(true)); + + } + + @Test + public void testEmptyToNull() { + + final List nullList = null; + final List listWithoutEntries = new ArrayList(); + final List listWithOneEntry = Arrays.asList(1); + + assertThat(Lists.emptyToNull(nullList), is(nullValue())); + assertThat(Lists.emptyToNull(listWithoutEntries), is(nullValue())); + assertThat(Lists.emptyToNull(listWithOneEntry), is(notNullValue())); + + } + +} diff --git a/src/test/java/com/rometools/utils/LongsTest.java b/rome-utils/src/test/java/com/rometools/utils/LongsTest.java similarity index 97% rename from src/test/java/com/rometools/utils/LongsTest.java rename to rome-utils/src/test/java/com/rometools/utils/LongsTest.java index 0955cfd..2069c04 100644 --- a/src/test/java/com/rometools/utils/LongsTest.java +++ b/rome-utils/src/test/java/com/rometools/utils/LongsTest.java @@ -1,40 +1,40 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.rometools.utils; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.nullValue; - -import org.junit.Test; - -public class LongsTest { - - @Test - public void testParseDecimal() { - - final String nullString = null; - final String emptyString = ""; - final String longString = String.valueOf(Long.MAX_VALUE); - final String decimalString = String.valueOf(Double.MAX_VALUE); - - assertThat(Longs.parseDecimal(nullString), is(nullValue())); - assertThat(Longs.parseDecimal(emptyString), is(nullValue())); - assertThat(Longs.parseDecimal(longString), is(Long.MAX_VALUE)); - assertThat(Longs.parseDecimal(decimalString), is((long) Double.MAX_VALUE)); - - } - -} +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.rometools.utils; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.nullValue; + +import org.junit.Test; + +public class LongsTest { + + @Test + public void testParseDecimal() { + + final String nullString = null; + final String emptyString = ""; + final String longString = String.valueOf(Long.MAX_VALUE); + final String decimalString = String.valueOf(Double.MAX_VALUE); + + assertThat(Longs.parseDecimal(nullString), is(nullValue())); + assertThat(Longs.parseDecimal(emptyString), is(nullValue())); + assertThat(Longs.parseDecimal(longString), is(Long.MAX_VALUE)); + assertThat(Longs.parseDecimal(decimalString), is((long) Double.MAX_VALUE)); + + } + +} diff --git a/src/test/java/com/rometools/utils/StringsTest.java b/rome-utils/src/test/java/com/rometools/utils/StringsTest.java similarity index 96% rename from src/test/java/com/rometools/utils/StringsTest.java rename to rome-utils/src/test/java/com/rometools/utils/StringsTest.java index ce72aa4..fd17c51 100644 --- a/src/test/java/com/rometools/utils/StringsTest.java +++ b/rome-utils/src/test/java/com/rometools/utils/StringsTest.java @@ -1,139 +1,139 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.rometools.utils; - -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.nullValue; -import static org.junit.Assert.assertThat; - -import org.junit.Test; - -public class StringsTest { - - @Test - public void testIsNull() { - - final String nullString = null; - final String emptyString = ""; - final String blankString = " "; - final String string = "a"; - - assertThat(Strings.isNull(nullString), is(true)); - assertThat(Strings.isNull(emptyString), is(false)); - assertThat(Strings.isNull(blankString), is(false)); - assertThat(Strings.isNull(string), is(false)); - - } - - @Test - public void testIsEmpty() { - - final String nullString = null; - final String emptyString = ""; - final String blankString = " "; - final String string = "a"; - - assertThat(Strings.isEmpty(nullString), is(true)); - assertThat(Strings.isEmpty(emptyString), is(true)); - assertThat(Strings.isEmpty(blankString), is(false)); - assertThat(Strings.isEmpty(string), is(false)); - - } - - @Test - public void testIsNotEmpty() { - - final String nullString = null; - final String emptyString = ""; - final String blankString = " "; - final String string = "a"; - - assertThat(Strings.isNotEmpty(nullString), is(false)); - assertThat(Strings.isNotEmpty(emptyString), is(false)); - assertThat(Strings.isNotEmpty(blankString), is(true)); - assertThat(Strings.isNotEmpty(string), is(true)); - } - - @Test - public void testIsBlank() { - - final String nullString = null; - final String emptyString = ""; - final String blankString = " "; - final String string = "a"; - - assertThat(Strings.isBlank(nullString), is(true)); - assertThat(Strings.isBlank(emptyString), is(true)); - assertThat(Strings.isBlank(blankString), is(true)); - assertThat(Strings.isBlank(string), is(false)); - } - - @Test - public void testTrim() { - - final String nullString = null; - final String emptyString = ""; - final String blankString = " "; - final String string = " a "; - - assertThat(Strings.trim(nullString), is(nullValue())); - assertThat(Strings.trim(emptyString), is("")); - assertThat(Strings.trim(blankString), is("")); - assertThat(Strings.trim(string), is("a")); - } - - @Test - public void testTrimToEmpty() { - - final String nullString = null; - final String emptyString = ""; - final String blankString = " "; - final String string = " a "; - - assertThat(Strings.trimToEmpty(nullString), is("")); - assertThat(Strings.trimToEmpty(emptyString), is("")); - assertThat(Strings.trimToEmpty(blankString), is("")); - assertThat(Strings.trimToEmpty(string), is("a")); - } - - @Test - public void testTrimToNull() { - - final String nullString = null; - final String emptyString = ""; - final String blankString = " "; - final String string = " a "; - - assertThat(Strings.trimToNull(nullString), is(nullValue())); - assertThat(Strings.trimToNull(emptyString), is(nullValue())); - assertThat(Strings.trimToNull(blankString), is(nullValue())); - assertThat(Strings.trimToNull(string), is("a")); - } - - @Test - public void testToLowerCase() { - - final String nullString = null; - final String emptyString = ""; - final String blankString = " "; - final String string = "A"; - - assertThat(Strings.toLowerCase(nullString), is(nullValue())); - assertThat(Strings.toLowerCase(emptyString), is("")); - assertThat(Strings.toLowerCase(blankString), is(" ")); - assertThat(Strings.toLowerCase(string), is("a")); - } - -} +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.rometools.utils; + +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.nullValue; +import static org.junit.Assert.assertThat; + +import org.junit.Test; + +public class StringsTest { + + @Test + public void testIsNull() { + + final String nullString = null; + final String emptyString = ""; + final String blankString = " "; + final String string = "a"; + + assertThat(Strings.isNull(nullString), is(true)); + assertThat(Strings.isNull(emptyString), is(false)); + assertThat(Strings.isNull(blankString), is(false)); + assertThat(Strings.isNull(string), is(false)); + + } + + @Test + public void testIsEmpty() { + + final String nullString = null; + final String emptyString = ""; + final String blankString = " "; + final String string = "a"; + + assertThat(Strings.isEmpty(nullString), is(true)); + assertThat(Strings.isEmpty(emptyString), is(true)); + assertThat(Strings.isEmpty(blankString), is(false)); + assertThat(Strings.isEmpty(string), is(false)); + + } + + @Test + public void testIsNotEmpty() { + + final String nullString = null; + final String emptyString = ""; + final String blankString = " "; + final String string = "a"; + + assertThat(Strings.isNotEmpty(nullString), is(false)); + assertThat(Strings.isNotEmpty(emptyString), is(false)); + assertThat(Strings.isNotEmpty(blankString), is(true)); + assertThat(Strings.isNotEmpty(string), is(true)); + } + + @Test + public void testIsBlank() { + + final String nullString = null; + final String emptyString = ""; + final String blankString = " "; + final String string = "a"; + + assertThat(Strings.isBlank(nullString), is(true)); + assertThat(Strings.isBlank(emptyString), is(true)); + assertThat(Strings.isBlank(blankString), is(true)); + assertThat(Strings.isBlank(string), is(false)); + } + + @Test + public void testTrim() { + + final String nullString = null; + final String emptyString = ""; + final String blankString = " "; + final String string = " a "; + + assertThat(Strings.trim(nullString), is(nullValue())); + assertThat(Strings.trim(emptyString), is("")); + assertThat(Strings.trim(blankString), is("")); + assertThat(Strings.trim(string), is("a")); + } + + @Test + public void testTrimToEmpty() { + + final String nullString = null; + final String emptyString = ""; + final String blankString = " "; + final String string = " a "; + + assertThat(Strings.trimToEmpty(nullString), is("")); + assertThat(Strings.trimToEmpty(emptyString), is("")); + assertThat(Strings.trimToEmpty(blankString), is("")); + assertThat(Strings.trimToEmpty(string), is("a")); + } + + @Test + public void testTrimToNull() { + + final String nullString = null; + final String emptyString = ""; + final String blankString = " "; + final String string = " a "; + + assertThat(Strings.trimToNull(nullString), is(nullValue())); + assertThat(Strings.trimToNull(emptyString), is(nullValue())); + assertThat(Strings.trimToNull(blankString), is(nullValue())); + assertThat(Strings.trimToNull(string), is("a")); + } + + @Test + public void testToLowerCase() { + + final String nullString = null; + final String emptyString = ""; + final String blankString = " "; + final String string = "A"; + + assertThat(Strings.toLowerCase(nullString), is(nullValue())); + assertThat(Strings.toLowerCase(emptyString), is("")); + assertThat(Strings.toLowerCase(blankString), is(" ")); + assertThat(Strings.toLowerCase(string), is("a")); + } + +} diff --git a/src/test/resources/.gitignore b/rome-utils/src/test/resources/.gitignore similarity index 100% rename from src/test/resources/.gitignore rename to rome-utils/src/test/resources/.gitignore