Skip to main content
added 7 characters in body
Source Link

Following are some observations that I found in this code -

  1. There is no need of taking limit as instance variable in this class. You are not using it and your code will work without it.

  2. Your split() method requires CharSequence as instance variable, but in code you are converting it into String e.g. -

    result.add(((String) toSplit).substring(start, i));

So, it will break your code, if input is other than String like StringBuffer and StringBuilder

  1. Below method will break if input separator contains any dangling character like "*" -

    public static Splitter on(final String separator)

This is because in below line, split() method of String class accepts a regex string -

String[] result = ((String) toSplit).split(separator);
  1. As per current logic, String separator is also using regex, so you can call Pattern separator method from this method -

    public static Splitter on(final String separator) { onreturn on(Pattern.compile(separator); }

  2. Regarding multi-threading, code looks fine and it would be able to work in multi-threaded environment.

Following are some observations that I found in this code -

  1. There is no need of taking limit as instance variable in this class. You are not using it and your code will work without it.

  2. Your split() method requires CharSequence as instance variable, but in code you are converting it into String e.g. -

    result.add(((String) toSplit).substring(start, i));

So, it will break your code, if input is other than String like StringBuffer and StringBuilder

  1. Below method will break if input separator contains any dangling character like "*" -

    public static Splitter on(final String separator)

This is because in below line, split() method of String class accepts a regex string -

String[] result = ((String) toSplit).split(separator);
  1. As per current logic, String separator is also using regex, so you can call Pattern separator method from this method -

    public static Splitter on(final String separator) { on(Pattern.compile(separator); }

  2. Regarding multi-threading, code looks fine and it would be able to work in multi-threaded environment.

Following are some observations that I found in this code -

  1. There is no need of taking limit as instance variable in this class. You are not using it and your code will work without it.

  2. Your split() method requires CharSequence as instance variable, but in code you are converting it into String e.g. -

    result.add(((String) toSplit).substring(start, i));

So, it will break your code, if input is other than String like StringBuffer and StringBuilder

  1. Below method will break if input separator contains any dangling character like "*" -

    public static Splitter on(final String separator)

This is because in below line, split() method of String class accepts a regex string -

String[] result = ((String) toSplit).split(separator);
  1. As per current logic, String separator is also using regex, so you can call Pattern separator method from this method -

    public static Splitter on(final String separator) { return on(Pattern.compile(separator); }

  2. Regarding multi-threading, code looks fine and it would be able to work in multi-threaded environment.

Source Link

Following are some observations that I found in this code -

  1. There is no need of taking limit as instance variable in this class. You are not using it and your code will work without it.

  2. Your split() method requires CharSequence as instance variable, but in code you are converting it into String e.g. -

    result.add(((String) toSplit).substring(start, i));

So, it will break your code, if input is other than String like StringBuffer and StringBuilder

  1. Below method will break if input separator contains any dangling character like "*" -

    public static Splitter on(final String separator)

This is because in below line, split() method of String class accepts a regex string -

String[] result = ((String) toSplit).split(separator);
  1. As per current logic, String separator is also using regex, so you can call Pattern separator method from this method -

    public static Splitter on(final String separator) { on(Pattern.compile(separator); }

  2. Regarding multi-threading, code looks fine and it would be able to work in multi-threaded environment.