Commit 06cf653d authored by Christian P. MOMON's avatar Christian P. MOMON
Browse files

Peformed a code review and Javadoc review.

parent 0845ab52
/** /*
* Copyright (C) 2013-2017 Christian Pierre MOMON * Copyright (C) 2013-2017 Christian Pierre MOMON
* *
* This file is part of devinsy-strings. * This file is part of devinsy-strings.
...@@ -21,14 +21,14 @@ package fr.devinsy.util.strings; ...@@ -21,14 +21,14 @@ package fr.devinsy.util.strings;
import java.util.Comparator; import java.util.Comparator;
/** /**
* * The Class StringLengthComparator.
*/ */
public class StringLengthComparator implements Comparator<String> public class StringLengthComparator implements Comparator<String>
{ {
private static StringLengthComparator instance; private static StringLengthComparator instance;
/** /* (non-Javadoc)
* * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
*/ */
@Override @Override
public int compare(final String alpha, final String bravo) public int compare(final String alpha, final String bravo)
...@@ -39,13 +39,10 @@ public class StringLengthComparator implements Comparator<String> ...@@ -39,13 +39,10 @@ public class StringLengthComparator implements Comparator<String>
Integer alphaValue; Integer alphaValue;
if (alpha == null) if (alpha == null)
{ {
//
alphaValue = null; alphaValue = null;
} }
else else
{ {
//
alphaValue = alpha.length(); alphaValue = alpha.length();
} }
...@@ -53,13 +50,10 @@ public class StringLengthComparator implements Comparator<String> ...@@ -53,13 +50,10 @@ public class StringLengthComparator implements Comparator<String>
Integer bravoValue; Integer bravoValue;
if (bravo == null) if (bravo == null)
{ {
//
bravoValue = null; bravoValue = null;
} }
else else
{ {
//
bravoValue = bravo.length(); bravoValue = bravo.length();
} }
...@@ -98,25 +92,18 @@ public class StringLengthComparator implements Comparator<String> ...@@ -98,25 +92,18 @@ public class StringLengthComparator implements Comparator<String>
// //
if ((alpha == null) && (bravo == null)) if ((alpha == null) && (bravo == null))
{ {
//
result = 0; result = 0;
} }
else if (alpha == null) else if (alpha == null)
{ {
//
result = -1; result = -1;
} }
else if (bravo == null) else if (bravo == null)
{ {
//
result = +1; result = +1;
} }
else else
{ {
//
result = alpha.compareTo(bravo); result = alpha.compareTo(bravo);
} }
...@@ -125,8 +112,9 @@ public class StringLengthComparator implements Comparator<String> ...@@ -125,8 +112,9 @@ public class StringLengthComparator implements Comparator<String>
} }
/** /**
* Instance.
* *
* @return * @return the string length comparator
*/ */
public static StringLengthComparator instance() public static StringLengthComparator instance()
{ {
......
/** /*
* Copyright (C) 2008-2010 Christian Pierre MOMON * Copyright (C) 2008-2010,2013-2015,2017 Christian Pierre MOMON
* Copyright (C) 2013-2015 Christian Pierre MOMON
* Copyright (C) 2017 Christian Pierre MOMON
* *
* This file is part of devinsy-strings. * This file is part of devinsy-strings.
* *
...@@ -323,9 +321,11 @@ public class StringList extends ArrayList<String> implements CharSequence ...@@ -323,9 +321,11 @@ public class StringList extends ArrayList<String> implements CharSequence
} }
/** /**
* Appendln.
* *
* @param string * @param string
* @return * the string
* @return the string list
*/ */
public StringList appendln(final Collection<String> string) public StringList appendln(final Collection<String> string)
{ {
...@@ -338,9 +338,11 @@ public class StringList extends ArrayList<String> implements CharSequence ...@@ -338,9 +338,11 @@ public class StringList extends ArrayList<String> implements CharSequence
} }
/** /**
* Appendln.
* *
* @param value * @param value
* @return * the value
* @return the string list
*/ */
public StringList appendln(final double value) public StringList appendln(final double value)
{ {
...@@ -353,9 +355,11 @@ public class StringList extends ArrayList<String> implements CharSequence ...@@ -353,9 +355,11 @@ public class StringList extends ArrayList<String> implements CharSequence
} }
/** /**
* Appendln.
* *
* @param value * @param value
* @return * the value
* @return the string list
*/ */
public StringList appendln(final int value) public StringList appendln(final int value)
{ {
...@@ -368,9 +372,11 @@ public class StringList extends ArrayList<String> implements CharSequence ...@@ -368,9 +372,11 @@ public class StringList extends ArrayList<String> implements CharSequence
} }
/** /**
* Appendln.
* *
* @param value * @param value
* @return * the value
* @return the string list
*/ */
public StringList appendln(final long value) public StringList appendln(final long value)
{ {
...@@ -383,9 +389,11 @@ public class StringList extends ArrayList<String> implements CharSequence ...@@ -383,9 +389,11 @@ public class StringList extends ArrayList<String> implements CharSequence
} }
/** /**
* Appendln.
* *
* @param value * @param value
* @return * the value
* @return the string list
*/ */
public StringList appendln(final Object value) public StringList appendln(final Object value)
{ {
...@@ -398,9 +406,11 @@ public class StringList extends ArrayList<String> implements CharSequence ...@@ -398,9 +406,11 @@ public class StringList extends ArrayList<String> implements CharSequence
} }
/** /**
* Appendln.
* *
* @param value * @param value
* @return * the value
* @return the string list
*/ */
public StringList appendln(final short value) public StringList appendln(final short value)
{ {
...@@ -413,9 +423,11 @@ public class StringList extends ArrayList<String> implements CharSequence ...@@ -413,9 +423,11 @@ public class StringList extends ArrayList<String> implements CharSequence
} }
/** /**
* Appendln.
* *
* @param string * @param string
* @return * the string
* @return the string list
*/ */
public StringList appendln(final String string) public StringList appendln(final String string)
{ {
...@@ -428,9 +440,11 @@ public class StringList extends ArrayList<String> implements CharSequence ...@@ -428,9 +440,11 @@ public class StringList extends ArrayList<String> implements CharSequence
} }
/** /**
* Appendln.
* *
* @param strings * @param strings
* @return * the strings
* @return the string list
*/ */
public StringList appendln(final String... strings) public StringList appendln(final String... strings)
{ {
...@@ -461,9 +475,11 @@ public class StringList extends ArrayList<String> implements CharSequence ...@@ -461,9 +475,11 @@ public class StringList extends ArrayList<String> implements CharSequence
} }
/** /**
* Char at.
* *
* @param position * @param position
* @return * the position
* @return the char
*/ */
public char charAt(final StringListCharPosition position) public char charAt(final StringListCharPosition position)
{ {
...@@ -480,7 +496,7 @@ public class StringList extends ArrayList<String> implements CharSequence ...@@ -480,7 +496,7 @@ public class StringList extends ArrayList<String> implements CharSequence
* Deep copy and shallow copy have no sense about a list of immutable * Deep copy and shallow copy have no sense about a list of immutable
* objects. * objects.
* *
* @return * @return the string list
*/ */
@Override @Override
public StringList clone() public StringList clone()
...@@ -499,9 +515,11 @@ public class StringList extends ArrayList<String> implements CharSequence ...@@ -499,9 +515,11 @@ public class StringList extends ArrayList<String> implements CharSequence
} }
/** /**
* Contains any.
* *
* @param source * @param target
* @return * the target
* @return true, if successful
*/ */
public boolean containsAny(final Collection<String> target) public boolean containsAny(final Collection<String> target)
{ {
...@@ -541,9 +559,11 @@ public class StringList extends ArrayList<String> implements CharSequence ...@@ -541,9 +559,11 @@ public class StringList extends ArrayList<String> implements CharSequence
} }
/** /**
* Contains any.
* *
* @param source * @param target
* @return * the target
* @return true, if successful
*/ */
public boolean containsAny(final String... target) public boolean containsAny(final String... target)
{ {
...@@ -587,8 +607,9 @@ public class StringList extends ArrayList<String> implements CharSequence ...@@ -587,8 +607,9 @@ public class StringList extends ArrayList<String> implements CharSequence
} }
/** /**
* Contains blank.
* *
* @return * @return true, if successful
*/ */
public boolean containsBlank() public boolean containsBlank()
{ {
...@@ -621,8 +642,9 @@ public class StringList extends ArrayList<String> implements CharSequence ...@@ -621,8 +642,9 @@ public class StringList extends ArrayList<String> implements CharSequence
} }
/** /**
* Contains empty.
* *
* @return * @return true, if successful
*/ */
public boolean containsEmpty() public boolean containsEmpty()
{ {
...@@ -655,8 +677,9 @@ public class StringList extends ArrayList<String> implements CharSequence ...@@ -655,8 +677,9 @@ public class StringList extends ArrayList<String> implements CharSequence
} }
/** /**
* Contains null.
* *
* @return * @return true, if successful
*/ */
public boolean containsNull() public boolean containsNull()
{ {
...@@ -689,9 +712,11 @@ public class StringList extends ArrayList<String> implements CharSequence ...@@ -689,9 +712,11 @@ public class StringList extends ArrayList<String> implements CharSequence
} }
/** /**
* Gets the by index.
* *
* @param id * @param id
* @return * the id
* @return the by index
*/ */
public String getByIndex(final int id) public String getByIndex(final int id)
{ {
...@@ -704,8 +729,9 @@ public class StringList extends ArrayList<String> implements CharSequence ...@@ -704,8 +729,9 @@ public class StringList extends ArrayList<String> implements CharSequence
} }
/** /**
* Gets the first.
* *
* @return * @return the first
*/ */
public String getFirst() public String getFirst()
{ {
...@@ -746,8 +772,9 @@ public class StringList extends ArrayList<String> implements CharSequence ...@@ -746,8 +772,9 @@ public class StringList extends ArrayList<String> implements CharSequence
} }
/** /**
* Gets the longest bytes line.
* *
* @return * @return the longest bytes line
*/ */
public String getLongestBytesLine() public String getLongestBytesLine()
{ {
...@@ -776,8 +803,9 @@ public class StringList extends ArrayList<String> implements CharSequence ...@@ -776,8 +803,9 @@ public class StringList extends ArrayList<String> implements CharSequence
} }
/** /**
* Gets the longest line.
* *
* @return * @return the longest line
*/ */
public String getLongestLine() public String getLongestLine()
{ {
...@@ -806,8 +834,9 @@ public class StringList extends ArrayList<String> implements CharSequence ...@@ -806,8 +834,9 @@ public class StringList extends ArrayList<String> implements CharSequence
} }
/** /**
* Gets the not blank.
* *
* @return * @return the not blank
*/ */
public StringList getNotBlank() public StringList getNotBlank()
{ {
...@@ -828,8 +857,9 @@ public class StringList extends ArrayList<String> implements CharSequence ...@@ -828,8 +857,9 @@ public class StringList extends ArrayList<String> implements CharSequence
} }
/** /**
* Gets the not empty.
* *
* @return * @return the not empty
*/ */
public StringList getNotEmpty() public StringList getNotEmpty()
{ {
...@@ -850,8 +880,9 @@ public class StringList extends ArrayList<String> implements CharSequence ...@@ -850,8 +880,9 @@ public class StringList extends ArrayList<String> implements CharSequence
} }
/** /**
* Gets the not null.
* *
* @return * @return the not null
*/ */
public StringList getNotNull() public StringList getNotNull()
{ {
...@@ -872,8 +903,9 @@ public class StringList extends ArrayList<String> implements CharSequence ...@@ -872,8 +903,9 @@ public class StringList extends ArrayList<String> implements CharSequence
} }
/** /**
* Gets the shortest bytes line.
* *
* @return * @return the shortest bytes line
*/ */
public String getShortestBytesLine() public String getShortestBytesLine()
{ {
...@@ -902,8 +934,9 @@ public class StringList extends ArrayList<String> implements CharSequence ...@@ -902,8 +934,9 @@ public class StringList extends ArrayList<String> implements CharSequence
} }
/** /**
* Gets the shortest line.
* *
* @return * @return the shortest line
*/ */
public String getShortestLine() public String getShortestLine()
{ {
...@@ -932,9 +965,11 @@ public class StringList extends ArrayList<String> implements CharSequence ...@@ -932,9 +965,11 @@ public class StringList extends ArrayList<String> implements CharSequence
} }
/** /**
* Index of.
* *
* @param index * @param index
* @return * the index
* @return the string list char position
*/ */
public StringListCharPosition indexOf(final int index) public StringListCharPosition indexOf(final int index)
{ {
...@@ -971,8 +1006,10 @@ public class StringList extends ArrayList<String> implements CharSequence ...@@ -971,8 +1006,10 @@ public class StringList extends ArrayList<String> implements CharSequence
} }
/** /**
* Index of next line not null.
* *
* @param startIndex * @param startIndex
* the start index
* @return the index of the next line not null, -1 otherwise. * @return the index of the next line not null, -1 otherwise.
*/ */
public int indexOfNextLineNotNull(final int startIndex) public int indexOfNextLineNotNull(final int startIndex)
...@@ -1008,9 +1045,11 @@ public class StringList extends ArrayList<String> implements CharSequence ...@@ -1008,9 +1045,11 @@ public class StringList extends ArrayList<String> implements CharSequence
} }
/** /**
* Checks if is out of bounds.
* *
* @param position * @param position
* @return * the position
* @return true, if is out of bounds
*/ */
public boolean isOutOfBounds(final StringListCharPosition position) public boolean isOutOfBounds(final StringListCharPosition position)
{ {
...@@ -1041,9 +1080,11 @@ public class StringList extends ArrayList<String> implements CharSequence ...@@ -1041,9 +1080,11 @@ public class StringList extends ArrayList<String> implements CharSequence
} }
/** /**
* Checks if is out of line.
* *
* @param position * @param position
* @return * the position
* @return true, if is out of line
*/ */
public boolean isOutOfLine(final StringListCharPosition position) public boolean isOutOfLine(final StringListCharPosition position)
{ {
...@@ -1070,9 +1111,11 @@ public class StringList extends ArrayList<String> implements CharSequence ...@@ -1070,9 +1111,11 @@ public class StringList extends ArrayList<String> implements CharSequence
}