java: no need to check for null before calling instanceof

the instanceof check returns false when passed a null value

Change-Id: I7742d0d9cf25ef23d9adee7328f701c7efeea8b5
This commit is contained in:
Noel Grandin 2014-08-20 13:48:58 +02:00
parent 831051f55e
commit 610f3388c7
6 changed files with 7 additions and 7 deletions

View file

@ -1603,7 +1603,7 @@ class util
static boolean isVoidAny(Object obj)
{
boolean ret= false;
if( obj != null && obj instanceof Any)
if(obj instanceof Any)
{
Any a= (Any) obj;
if( a.getType().getTypeClass().equals( TypeClass.INTERFACE)

View file

@ -323,7 +323,7 @@ public class JavaLoader implements XImplementationLoader,
try {
if (null != compfac_method) {
Object ret = compfac_method.invoke( clazz, new Object [] { implementationName } );
if (null == ret || !(ret instanceof XSingleComponentFactory))
if (!(ret instanceof XSingleComponentFactory))
throw new CannotActivateFactoryException(
"No factory object for " + implementationName );

View file

@ -71,7 +71,7 @@ public class Parameters implements XPropertySet {
public String get(String paramName) {
Object res = parameters.get(paramName);
if (res != null && res instanceof String)
if (res instanceof String)
return (String)res;
if (defaults != null)

View file

@ -61,7 +61,7 @@ public class SysUtils {
for (int i = 0; i < dfs.length; i++) {
if (dfs[i].MimeType.startsWith("text/plain")) {
Object data = xTrans.getTransferData(dfs[i]);
if (data != null && data instanceof String) {
if (data instanceof String) {
return (String) data;
}
}

View file

@ -95,7 +95,7 @@ public class _XCellRangesQuery extends MultiMethodTest {
// and the environment has to be disposed: this is necessary for objects
// that do not make entries on the sheet themselves
Object o = tEnv.getObjRelation("XCellRangesQuery.CREATEENTRIES");
if (o != null && o instanceof Boolean) {
if (o instanceof Boolean) {
bMakeEntriesAndDispose = ((Boolean)o).booleanValue();
}
if(bMakeEntriesAndDispose) {

View file

@ -52,7 +52,7 @@ public class AccessibilityTreeModelBase
Object aChild = null;
try
{
if (aParent != null && aParent instanceof AccessibleTreeNode)
if (aParent instanceof AccessibleTreeNode)
aChild = ((AccessibleTreeNode)aParent).getChild(nIndex);
else
System.out.println ("getChild called for unknown parent node");
@ -69,7 +69,7 @@ public class AccessibilityTreeModelBase
Object aChild = null;
try
{
if (aParent != null && aParent instanceof AccessibleTreeNode)
if (aParent instanceof AccessibleTreeNode)
aChild = ((AccessibleTreeNode)aParent).getChildNoCreate(nIndex);
else
System.out.println ("getChild called for unknown parent node");