Skip to content

Code cleanup #632

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Apr 19, 2017
2 changes: 1 addition & 1 deletion Parse/src/main/java/com/parse/ConfigCallback.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ public interface ConfigCallback extends ParseCallback2<ParseConfig, ParseExcepti
* The exception raised by the fetch, or {@code null} if it succeeded.
*/
@Override
public void done(ParseConfig config, ParseException e);
void done(ParseConfig config, ParseException e);
}
2 changes: 1 addition & 1 deletion Parse/src/main/java/com/parse/CountCallback.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@ public interface CountCallback {
* @param e
* The exception raised by the count, or null if it succeeded.
*/
public void done(int count, ParseException e);
void done(int count, ParseException e);
}
2 changes: 1 addition & 1 deletion Parse/src/main/java/com/parse/DeleteCallback.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ public interface DeleteCallback extends ParseCallback1<ParseException> {
* The exception raised by the delete, or {@code null} if it succeeded.
*/
@Override
public void done(ParseException e);
void done(ParseException e);
}
2 changes: 1 addition & 1 deletion Parse/src/main/java/com/parse/FindCallback.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@ public interface FindCallback<T extends ParseObject> extends ParseCallback2<List
* The exception raised by the save, or null if it succeeded.
*/
@Override
public void done(List<T> objects, ParseException e);
void done(List<T> objects, ParseException e);
}
2 changes: 1 addition & 1 deletion Parse/src/main/java/com/parse/FunctionCallback.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@ public interface FunctionCallback<T> extends ParseCallback2<T, ParseException> {
* The exception raised by the cloud call, or {@code null} if it succeeded.
*/
@Override
public void done(T object, ParseException e);
void done(T object, ParseException e);
}
2 changes: 1 addition & 1 deletion Parse/src/main/java/com/parse/GetCallback.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,5 @@ public interface GetCallback<T extends ParseObject> extends ParseCallback2<T, Pa
* The exception raised by the fetch, or {@code null} if it succeeded.
*/
@Override
public void done(T object, ParseException e);
void done(T object, ParseException e);
}
2 changes: 1 addition & 1 deletion Parse/src/main/java/com/parse/GetDataCallback.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ public interface GetDataCallback extends ParseCallback2<byte[], ParseException>
* The exception raised by the fetch, or {@code null} if it succeeded.
*/
@Override
public void done(byte[] data, ParseException e);
void done(byte[] data, ParseException e);
}

2 changes: 1 addition & 1 deletion Parse/src/main/java/com/parse/GetDataStreamCallback.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ public interface GetDataStreamCallback extends ParseCallback2<InputStream, Parse
* The exception raised by the fetch, or {@code null} if it succeeded.
*/
@Override
public void done(InputStream input, ParseException e);
void done(InputStream input, ParseException e);
}
2 changes: 1 addition & 1 deletion Parse/src/main/java/com/parse/GetFileCallback.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ public interface GetFileCallback extends ParseCallback2<File, ParseException> {
* The exception raised by the fetch, or {@code null} if it succeeded.
*/
@Override
public void done(File file, ParseException e);
void done(File file, ParseException e);
}
2 changes: 1 addition & 1 deletion Parse/src/main/java/com/parse/LocationCallback.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@ public interface LocationCallback extends ParseCallback2<ParseGeoPoint, ParseExc
* The exception raised by the location fetch, or {@code null} if it succeeded.
*/
@Override
public void done(ParseGeoPoint geoPoint, ParseException e);
void done(ParseGeoPoint geoPoint, ParseException e);
}
2 changes: 1 addition & 1 deletion Parse/src/main/java/com/parse/LocationNotifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
/* package */ static Task<Location> getCurrentLocationAsync(Context context,
long timeout, Criteria criteria) {
final TaskCompletionSource<Location> tcs = new TaskCompletionSource<>();
final Capture<ScheduledFuture<?>> timeoutFuture = new Capture<ScheduledFuture<?>>();
final Capture<ScheduledFuture<?>> timeoutFuture = new Capture<>();
final LocationManager manager =
(LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
final LocationListener listener = new LocationListener() {
Expand Down
4 changes: 2 additions & 2 deletions Parse/src/main/java/com/parse/LockSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
import java.util.concurrent.locks.Lock;

/** package */ class LockSet {
private static WeakHashMap<Lock, Long> stableIds = new WeakHashMap<Lock, Long>();
private static final WeakHashMap<Lock, Long> stableIds = new WeakHashMap<>();
private static long nextStableId = 0L;

private final Set<Lock> locks;

public LockSet(Collection<Lock> locks) {
this.locks = new TreeSet<Lock>(new Comparator<Lock>() {
this.locks = new TreeSet<>(new Comparator<Lock>() {
@Override
public int compare(Lock lhs, Lock rhs) {
Long lhsId = getStableId(lhs);
Expand Down
2 changes: 1 addition & 1 deletion Parse/src/main/java/com/parse/LogInCallback.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,5 @@ public interface LogInCallback extends ParseCallback2<ParseUser, ParseException>
* The exception raised by the login, or {@code null} if it succeeded.
*/
@Override
public void done(ParseUser user, ParseException e);
void done(ParseUser user, ParseException e);
}
2 changes: 1 addition & 1 deletion Parse/src/main/java/com/parse/LogOutCallback.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ public interface LogOutCallback extends ParseCallback1<ParseException> {
* The exception raised by the log out, or {@code null} if it succeeded.
*/
@Override
public void done(ParseException e);
void done(ParseException e);
}
2 changes: 1 addition & 1 deletion Parse/src/main/java/com/parse/ManifestInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ private static boolean hasAnyGcmSpecificDeclaration() {
}

private static boolean isGooglePlayServicesAvailable() {
return Build.VERSION.SDK_INT >= 8 && getPackageInfo("com.google.android.gsf") != null;
return getPackageInfo("com.google.android.gsf") != null;
}

private static ManifestCheckResult gcmSupportLevel() {
Expand Down
4 changes: 2 additions & 2 deletions Parse/src/main/java/com/parse/NotificationCompat.java
Original file line number Diff line number Diff line change
Expand Up @@ -314,15 +314,15 @@ public Builder setStyle(Style style) {
*/
@Deprecated
public Notification getNotification() {
return (Notification) IMPL.build(this);
return IMPL.build(this);
}

/**
* Combine all of the options that have been set and return a new {@link Notification}
* object.
*/
public Notification build() {
return (Notification) IMPL.build(this);
return IMPL.build(this);
}

protected static CharSequence limitCharSequenceLength(CharSequence cs) {
Expand Down
2 changes: 1 addition & 1 deletion Parse/src/main/java/com/parse/OfflineStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public Task<Void> then(Task<Void> ignore) throws Exception {
}
}
tasks.clear();
return Task.forResult((Void) null);
return Task.forResult(null);
}
}
});
Expand Down
9 changes: 0 additions & 9 deletions Parse/src/main/java/com/parse/Parse.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@
import android.util.Log;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashSet;
Expand Down Expand Up @@ -545,8 +543,6 @@ static void checkCacheApplicationId() {
f.close();
String diskApplicationId = new String(bytes, "UTF-8");
matches = diskApplicationId.equals(applicationId);
} catch (FileNotFoundException e) {
// Well, it existed a minute ago. Let's assume it doesn't match.
} catch (IOException e) {
// Hmm, the applicationId file was malformed or something. Assume it
// doesn't match.
Expand All @@ -568,11 +564,6 @@ static void checkCacheApplicationId() {
FileOutputStream out = new FileOutputStream(applicationIdFile);
out.write(applicationId.getBytes("UTF-8"));
out.close();
} catch (FileNotFoundException e) {
// Nothing we can really do about it.
} catch (UnsupportedEncodingException e) {
// Nothing we can really do about it. This would mean Java doesn't
// understand UTF-8, which is unlikely.
} catch (IOException e) {
// Nothing we can really do about it.
}
Expand Down
2 changes: 1 addition & 1 deletion Parse/src/main/java/com/parse/ParseCallback1.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@
* @param t
* Generally an {@link Throwable} that was thrown by the operation, if there was any.
*/
public void done(T t);
void done(T t);
}
2 changes: 1 addition & 1 deletion Parse/src/main/java/com/parse/ParseCallback2.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@
* @param t2
* Generally an {@link Throwable} that was thrown by the operation, if there was any.
*/
public void done(T1 t1, T2 t2);
void done(T1 t1, T2 t2);
}
2 changes: 1 addition & 1 deletion Parse/src/main/java/com/parse/ParseCommandCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ public void setConnected(boolean connected) {
*/
private <T> T waitForTaskWithoutLock(Task<T> task) throws ParseException {
synchronized (lock) {
final Capture<Boolean> finished = new Capture<Boolean>(false);
final Capture<Boolean> finished = new Capture<>(false);
task.continueWith(new Continuation<T, Void>() {
@Override
public Void then(Task<T> task) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void writeTo(OutputStream output) throws IOException {
throw new IllegalArgumentException("Output stream may not be null");
}

final FileInputStream fileInput = new FileInputStream(file);;
final FileInputStream fileInput = new FileInputStream(file);
try {
byte[] buffer = new byte[DEFAULT_CHUNK_SIZE];
int n;
Expand Down
18 changes: 6 additions & 12 deletions Parse/src/main/java/com/parse/ParseFileUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public static FileInputStream openInputStream(File file) throws IOException {
if (file.isDirectory()) {
throw new IOException("File '" + file + "' exists but is a directory");
}
if (file.canRead() == false) {
if (!file.canRead()) {
throw new IOException("File '" + file + "' cannot be read");
}
} else {
Expand Down Expand Up @@ -148,13 +148,13 @@ public static FileOutputStream openOutputStream(File file) throws IOException {
if (file.isDirectory()) {
throw new IOException("File '" + file + "' exists but is a directory");
}
if (file.canWrite() == false) {
if (!file.canWrite()) {
throw new IOException("File '" + file + "' cannot be written to");
}
} else {
File parent = file.getParentFile();
if (parent != null && parent.exists() == false) {
if (parent.mkdirs() == false) {
if (parent != null && !parent.exists()) {
if (!parent.mkdirs()) {
throw new IOException("File '" + file + "' could not be created");
}
}
Expand All @@ -170,7 +170,6 @@ public static FileOutputStream openOutputStream(File file) throws IOException {
* @param srcFile the file to be moved
* @param destFile the destination file
* @throws NullPointerException if source or destination is {@code null}
* @throws FileExistsException if the destination file exists
* @throws IOException if source or destination is invalid
* @throws IOException if an IO error occurs moving the file
* @since 1.4
Expand Down Expand Up @@ -225,7 +224,6 @@ public static void moveFile(final File srcFile, final File destFile) throws IOEx
* @throws IOException if source or destination is invalid
* @throws IOException if an IO error occurs during copying
* @throws IOException if the output file length is not the same as the input file length after the copy completes
* @see #copyFileToDirectory(File, File)
* @see #copyFile(File, File, boolean)
*/
public static void copyFile(final File srcFile, final File destFile) throws IOException {
Expand Down Expand Up @@ -255,7 +253,6 @@ public static void copyFile(final File srcFile, final File destFile) throws IOEx
* @throws IOException if source or destination is invalid
* @throws IOException if an IO error occurs during copying
* @throws IOException if the output file length is not the same as the input file length after the copy completes
* @see #copyFileToDirectory(File, File, boolean)
* @see #doCopyFile(File, File, boolean)
*/
public static void copyFile(final File srcFile, final File destFile,
Expand All @@ -266,7 +263,7 @@ public static void copyFile(final File srcFile, final File destFile,
if (destFile == null) {
throw new NullPointerException("Destination must not be null");
}
if (srcFile.exists() == false) {
if (!srcFile.exists()) {
throw new FileNotFoundException("Source '" + srcFile + "' does not exist");
}
if (srcFile.isDirectory()) {
Expand All @@ -281,7 +278,7 @@ public static void copyFile(final File srcFile, final File destFile,
throw new IOException("Destination '" + parentFile + "' directory cannot be created");
}
}
if (destFile.exists() && destFile.canWrite() == false) {
if (destFile.exists() && !destFile.canWrite()) {
throw new IOException("Destination '" + destFile + "' exists but is read-only");
}
doCopyFile(srcFile, destFile, preserveFileDate);
Expand Down Expand Up @@ -476,9 +473,6 @@ public static void forceDelete(final File file) throws IOException {
* Will not return true if there is a Symbolic Link anywhere in the path,
* only if the specific file is.
* <p>
* <b>Note:</b> the current implementation always returns {@code false} if the system
* is detected as Windows using {@link FilenameUtils#isSystemWindows()}
* <p>
* For code that runs on Java 1.7 or later, use the following method instead:
* <br>
* {@code boolean java.nio.file.Files.isSymbolicLink(Path path)}
Expand Down
Loading