private String toStringSafely(CharSequence csq) { String asString = csq.toString(); if (asString.length() == csq.length()) { return asString; } else { // It's pretty easy to implement CharSequence.toString() incorrectly // http://stackoverflow.com/a/15870428/1153071 // but for String, we know we won't have them, thus the fast-path above Errors.log().accept(new IllegalArgumentException(csq.getClass() + " did not implement toString() correctly.")); char[] chars = new char[csq.length()]; for (int i = 0; i < chars.length; ++i) { chars[i] = csq.charAt(i); } return new String(chars); } }
private String toStringSafely(CharSequence csq) { String asString = csq.toString(); if (asString.length() == csq.length()) { return asString; } else { // It's pretty easy to implement CharSequence.toString() incorrectly // http://stackoverflow.com/a/15870428/1153071 // but for String, we know we won't have them, thus the fast-path above Errors.log().accept(new IllegalArgumentException(csq.getClass() + " did not implement toString() correctly.")); char[] chars = new char[csq.length()]; for (int i = 0; i < chars.length; ++i) { chars[i] = csq.charAt(i); } return new String(chars); } }
private String toStringSafely(CharSequence csq) { String asString = csq.toString(); if (asString.length() == csq.length()) { return asString; } else { // It's pretty easy to implement CharSequence.toString() incorrectly // http://stackoverflow.com/a/15870428/1153071 // but for String, we know we won't have them, thus the fast-path above Errors.log().accept(new IllegalArgumentException(csq.getClass() + " did not implement toString() correctly.")); char[] chars = new char[csq.length()]; for (int i = 0; i < chars.length; ++i) { chars[i] = csq.charAt(i); } return new String(chars); } }
Errors.log().accept(new IllegalArgumentException("Couldn't find a good monospaced font.")); bestSystemMonospaceFontData = display.getSystemFont().getFontData()[0]; return bestSystemMonospaceFontData;