GT-2875 - Unswingable - review fixes

This commit is contained in:
dragonmacher 2019-05-21 14:51:32 -04:00
parent 5e8340b7f8
commit 31f3cca1a5
27 changed files with 100 additions and 79 deletions

View file

@ -1,53 +0,0 @@
/* ###
* IP: GHIDRA
*
* 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 ghidra.generic.function;
/**
* A generic functional interface that is more semantically sound than {@link Runnable}. Use
* anywhere you wish to have a generic callback function.
*/
@FunctionalInterface
public interface Callback {
/**
* Creates a dummy callback function. This is useful to avoid using <tt>null</tt>.
* @return a dummy callback function
*/
public static Callback dummy() {
return () -> {
// no-op
};
}
/**
* Returns the given callback object if it is not <tt>null</tt>. Otherwise, a {@link #dummy()}
* callback is returned. This is useful to avoid using <tt>null</tt>.
*
* @param c the callback function to check for <tt>null</tt>
* @return a non-null callback function
*/
public static Callback dummyIfNull(Callback c) {
if (c == null) {
return dummy();
}
return c;
}
/**
* The method that will be called.
*/
public void call();
}

View file

@ -1,33 +0,0 @@
/* ###
* IP: GHIDRA
*
* 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 ghidra.generic.function;
/**
* A generic functional interface that is more semantically sound than {@link Runnable}. Use
* anywhere you wish to have a generic callback function and you need to throw an exception.
*
* @param <E> the exception of your choice
*/
@FunctionalInterface
public interface ExceptionalCallback<E extends Exception> {
/**
* The method that will be called
*
* @throws Exception if the call throws an exception
*/
public void call() throws E;
}

View file

@ -1,35 +0,0 @@
/* ###
* IP: GHIDRA
*
* 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 ghidra.generic.function;
/**
* A generic functional interface that allows you to consume an item and potentially throw
* an exception.
*
* @param <T> the input type
* @param <E> the exception of your choice
*/
@FunctionalInterface
public interface ExceptionalConsumer<T, E extends Exception> {
/**
* The method that will be called
*
* @param t the input
* @throws E if the call throws an exception
*/
public void accept(T t) throws E;
}

View file

@ -1,37 +0,0 @@
/* ###
* IP: GHIDRA
*
* 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 ghidra.generic.function;
/**
* A generic functional interface that allows you to consume an item, return a result,
* and potentially throw an exception.
*
* @param <I> the input type
* @param <R> the result type
* @param <E> the exception of your choice
*/
@FunctionalInterface
public interface ExceptionalFunction<I, R, E extends Exception> {
/**
* The method that will be called
*
* @param i the input
* @return the result of the call
* @throws E if the call throws an exception
*/
public R apply(I i) throws E;
}

View file

@ -37,7 +37,7 @@ public class TaskUtilities {
}
/**
* Removes the given listener added via {@link #addTrackedTask(Task)}.
* Removes the given listener added via {@link #addTrackedTask(Task,TaskMonitor)}.
* @param listener The listener that needs to be removed.
*/
public static void removeTrackedTaskListener(TrackedTaskListener listener) {

View file

@ -19,12 +19,12 @@ import java.util.Objects;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import ghidra.generic.function.Callback;
import ghidra.util.SystemUtilities;
import ghidra.util.exception.CancelledException;
import ghidra.util.exception.TimeoutException;
import ghidra.util.timer.GTimer;
import ghidra.util.timer.GTimerMonitor;
import utility.function.Callback;
/**
* A task monitor that allows clients the ability to specify a timeout after which this monitor