Replaced isInstance method by instanceOf operator (#2620)

Added if brackets to single statement if-blocks

Replaced isinstance method by instanceOf operator

Revert "Added if brackets to single statement if-blocks"

This reverts commit 8e875fbf9ef9724e9d3b89f08fd396aa90865814.
This commit is contained in:
Ekta Mishra 2020-05-14 12:02:50 +05:30 committed by GitHub
parent d7d567439e
commit 83a4fb4b25
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 27 additions and 36 deletions

View File

@ -23,15 +23,14 @@
******************************************************************************/
package org.openrefine.wikidata.qa;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import org.jsoup.helper.Validate;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.jsoup.helper.Validate;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
/**
* A class to represent a QA warning emitted by the Wikidata schema This could
@ -155,7 +154,7 @@ public class QAWarning implements Comparable<QAWarning> {
@Override
public boolean equals(Object other) {
if (other == null || !QAWarning.class.isInstance(other)) {
if (!(other instanceof QAWarning)) {
return false;
}
QAWarning otherWarning = (QAWarning) other;

View File

@ -14,7 +14,7 @@ public class CalendarScrutinizer extends ValueScrutinizer {
@Override
public void scrutinize(Value value) {
if(TimeValue.class.isInstance(value)) {
if(value instanceof TimeValue) {
TimeValue time = (TimeValue)value;
if(time.getPreferredCalendarModel().equals(earliestGregorian.getPreferredCalendarModel()) &&
time.getPrecision() >= 10 &&

View File

@ -23,16 +23,16 @@
******************************************************************************/
package org.openrefine.wikidata.qa.scrutinizers;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Pattern;
import org.openrefine.wikidata.qa.QAWarning;
import org.wikidata.wdtk.datamodel.interfaces.EntityIdValue;
import org.wikidata.wdtk.datamodel.interfaces.PropertyIdValue;
import org.wikidata.wdtk.datamodel.interfaces.Snak;
import org.wikidata.wdtk.datamodel.interfaces.StringValue;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Pattern;
/**
* A scrutinizer that detects incorrect formats in text values (mostly
* identifiers).
@ -74,7 +74,7 @@ public class FormatScrutinizer extends SnakScrutinizer {
@Override
public void scrutinize(Snak snak, EntityIdValue entityId, boolean added) {
if (StringValue.class.isInstance(snak.getValue())) {
if (snak.getValue() instanceof StringValue) {
String value = ((StringValue) snak.getValue()).getString();
PropertyIdValue pid = snak.getPropertyId();
Pattern pattern = getPattern(pid);

View File

@ -23,19 +23,15 @@
******************************************************************************/
package org.openrefine.wikidata.qa.scrutinizers;
import org.openrefine.wikidata.qa.QAWarning;
import org.wikidata.wdtk.datamodel.interfaces.*;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.openrefine.wikidata.qa.QAWarning;
import org.wikidata.wdtk.datamodel.interfaces.EntityIdValue;
import org.wikidata.wdtk.datamodel.interfaces.ItemIdValue;
import org.wikidata.wdtk.datamodel.interfaces.PropertyIdValue;
import org.wikidata.wdtk.datamodel.interfaces.Statement;
import org.wikidata.wdtk.datamodel.interfaces.Value;
/**
* A scrutinizer that checks for missing inverse statements in edit batches.
*
@ -82,7 +78,7 @@ public class InverseConstraintScrutinizer extends StatementScrutinizer {
}
Value mainSnakValue = statement.getClaim().getMainSnak().getValue();
if (ItemIdValue.class.isInstance(mainSnakValue)) {
if (mainSnakValue instanceof ItemIdValue) {
PropertyIdValue pid = statement.getClaim().getMainSnak().getPropertyId();
PropertyIdValue inversePid = getInverseConstraint(pid);
if (inversePid != null) {

View File

@ -1,13 +1,9 @@
package org.openrefine.wikidata.qa.scrutinizers;
import java.util.Set;
import org.openrefine.wikidata.qa.QAWarning;
import org.wikidata.wdtk.datamodel.interfaces.EntityIdValue;
import org.wikidata.wdtk.datamodel.interfaces.ItemIdValue;
import org.wikidata.wdtk.datamodel.interfaces.PropertyIdValue;
import org.wikidata.wdtk.datamodel.interfaces.QuantityValue;
import org.wikidata.wdtk.datamodel.interfaces.Snak;
import org.wikidata.wdtk.datamodel.interfaces.*;
import java.util.Set;
/**
* Scrutinizer checking for units and bounds in quantities.
@ -24,7 +20,7 @@ public class QuantityScrutinizer extends SnakScrutinizer {
@Override
public void scrutinize(Snak snak, EntityIdValue entityId, boolean added) {
if (QuantityValue.class.isInstance(snak.getValue()) && added) {
if (snak.getValue() instanceof QuantityValue && added) {
PropertyIdValue pid = snak.getPropertyId();
QuantityValue value = (QuantityValue)snak.getValue();

View File

@ -23,16 +23,16 @@
******************************************************************************/
package org.openrefine.wikidata.qa.scrutinizers;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.regex.Pattern;
import org.openrefine.wikidata.qa.QAWarning;
import org.wikidata.wdtk.datamodel.interfaces.MonolingualTextValue;
import org.wikidata.wdtk.datamodel.interfaces.StringValue;
import org.wikidata.wdtk.datamodel.interfaces.Value;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.regex.Pattern;
/**
* Scrutinizes strings for trailing / leading whitespace, and others
*
@ -57,9 +57,9 @@ public class WhitespaceScrutinizer extends ValueScrutinizer {
@Override
public void scrutinize(Value value) {
String str = null;
if (MonolingualTextValue.class.isInstance(value)) {
if (value instanceof MonolingualTextValue) {
str = ((MonolingualTextValue) value).getText();
} else if (StringValue.class.isInstance(value)) {
} else if (value instanceof StringValue) {
str = ((StringValue) value).getString();
}