From c4935897211c60998b0b64788226c8cc40fc62e1 Mon Sep 17 00:00:00 2001 From: Maxim Date: Fri, 8 Dec 2023 17:42:19 +0300 Subject: [PATCH] Refactoring --- .../verapdf/component/AuditDurationImpl.java | 6 ++-- .../component/ComponentDetailsImpl.java | 4 +-- .../java/org/verapdf/core/JAXBCollection.java | 4 +-- .../org/verapdf/core/MapBackedDirectory.java | 2 +- .../org/verapdf/core/MapBackedRegistry.java | 6 ++-- .../java/org/verapdf/core/XmlSerialiser.java | 2 +- .../core/utils/AbstractFileOutputMapper.java | 2 +- .../core/utils/RelativeDirectoryMapper.java | 2 +- .../verapdf/core/utils/VersioningMapper.java | 10 +++--- .../features/AbstractFeaturesExtractor.java | 2 +- .../features/FeatureExtractionResult.java | 12 +++---- .../verapdf/features/FeaturesReporter.java | 12 +++---- .../verapdf/features/FontFeaturesData.java | 24 ++++++------- .../verapdf/features/ImageFeaturesData.java | 2 +- .../features/SignatureFeaturesData.java | 14 ++++---- .../objects/EmbeddedFileFeaturesObject.java | 2 +- .../org/verapdf/features/objects/Feature.java | 2 +- .../features/objects/FeaturesObject.java | 2 +- .../objects/FeaturesStructureContainer.java | 4 +-- .../features/objects/FontFeaturesObject.java | 10 +++--- .../objects/ImageXObjectFeaturesObject.java | 28 +++++++-------- .../objects/LowLvlInfoFeaturesObject.java | 2 +- .../verapdf/features/tools/ErrorsHelper.java | 6 ++-- .../features/tools/FeatureTreeNode.java | 7 ++-- .../metadata/fixer/FixerConfigImpl.java | 4 +-- .../parser/XMLProcessedObjectsParser.java | 2 +- .../axl/AXLExtensionSchemaDefinition.java | 12 ++++--- .../impl/axl/AXLExtensionSchemaField.java | 12 ++++--- .../impl/axl/AXLExtensionSchemaObject.java | 2 +- .../impl/axl/AXLExtensionSchemaProperty.java | 14 ++++---- .../impl/axl/AXLExtensionSchemaValueType.java | 12 ++++--- .../axl/AXLExtensionSchemasContainer.java | 4 +-- .../model/impl/axl/AXLPDFAIdentification.java | 2 +- .../impl/axl/AXLPDFUAIdentification.java | 2 +- .../verapdf/model/impl/axl/AXLXMPPackage.java | 2 +- .../model/impl/axl/AXLXMPProperty.java | 15 ++++---- .../xmp/PredefinedSchemasDefinition.java | 8 ++--- .../model/tools/xmp/SchemasDefinition.java | 6 ++-- .../model/tools/xmp/ValidatorsContainer.java | 4 +-- .../tools/xmp/ValidatorsContainerCreator.java | 2 +- .../xmp/validators/ArrayTypeValidator.java | 6 ++-- .../xmp/validators/SimpleTypeValidator.java | 6 ++-- .../validators/StructuredTypeValidator.java | 6 ++-- ...uredTypeWithRestrictedFieldsValidator.java | 8 ++--- .../main/java/org/verapdf/pdfa/Foundries.java | 2 +- .../verapdf/pdfa/flavours/PDFAFlavour.java | 2 +- .../pdfa/parsers/pkcs7/DEREncodedValue.java | 2 +- .../pdfa/results/MetadataFixerResultImpl.java | 10 ++---- .../pdfa/results/ValidationResultImpl.java | 13 +++---- .../profiles/ErrorArgumentImpl.java | 2 +- .../validation/profiles/ErrorDetailsImpl.java | 4 +-- .../profiles/ProfileDirectoryImpl.java | 4 +-- .../pdfa/validation/profiles/Profiles.java | 2 +- .../validation/profiles/ReferenceImpl.java | 2 +- .../pdfa/validation/profiles/RuleImpl.java | 4 +-- .../profiles/ValidationProfileImpl.java | 15 ++++---- .../validation/profiles/VariableImpl.java | 2 +- .../validation/validators/BaseValidator.java | 6 ++-- .../validators/JavaScriptEvaluator.java | 8 ++--- .../org/verapdf/policy/PolicyChecker.java | 1 - .../verapdf/policy/SchematronGenerator.java | 8 ++--- .../verapdf/policy/SchematronOperation.java | 8 ++--- .../processor/AbstractBatchHandler.java | 30 ++++++++-------- .../processor/AbstractBatchProcessor.java | 1 + .../verapdf/processor/AbstractXmlHandler.java | 16 ++++----- .../processor/FeaturesNodeSerializer.java | 1 + .../processor/ProcessorConfigImpl.java | 15 ++++---- .../verapdf/processor/ProcessorFactory.java | 8 ++--- .../org/verapdf/processor/ProcessorImpl.java | 6 ++-- .../processor/ProcessorResultImpl.java | 2 +- .../processor/SingleLineResultHandler.java | 4 +-- .../org/verapdf/processor/TaskResultImpl.java | 6 ++-- .../processor/VeraPDFExceptionSerializer.java | 1 + .../processor/plugins/PluginConfig.java | 4 +-- .../plugins/PluginsCollectionConfig.java | 4 +-- .../verapdf/processor/reports/CheckImpl.java | 1 + .../processor/reports/FixerReportImpl.java | 2 +- .../processor/reports/ResultStructure.java | 2 +- .../processor/reports/RuleSummaryImpl.java | 2 +- .../processor/reports/Summarisers.java | 2 +- .../reports/ValidationDetailsImpl.java | 4 +-- .../MultiThreadProcessingHandlerImpl.java | 2 +- .../writer/AbstractXmlReportWriter.java | 1 + .../multithread/writer/JsonReportWriter.java | 1 + .../multithread/writer/MrrReportWriter.java | 8 ++--- .../multithread/writer/RawReportWriter.java | 12 +++---- .../writer/ReportParserEventHandler.java | 18 +++++----- .../multithread/writer/ReportWriter.java | 4 +-- .../java/org/verapdf/report/FeaturesNode.java | 8 ++--- .../org/verapdf/report/FeaturesReport.java | 2 +- .../verapdf/version/VersionNumberImpl.java | 4 +-- .../java/org/verapdf/ReleaseDetailsTest.java | 2 +- .../impl/axl/XMPExtensionSchemaTest.java | 36 +++++++++---------- .../model/impl/axl/XMPIdentificationTest.java | 10 +++--- .../model/impl/axl/XMPMMHistoryTest.java | 12 +++---- .../impl/axl/XMPPropertiesNumberTest.java | 8 ++--- .../verapdf/pdfa/parsers/pkcs7/PKCS7Test.java | 4 +-- .../verapdf/pdfa/results/LocationTest.java | 2 +- .../pdfa/results/ValidationResultTest.java | 2 +- .../profiles/ProfileDirectoryImplTest.java | 10 +++--- .../profiles/ReferenceImplTest.java | 2 +- .../validation/profiles/RuleIdImplTest.java | 2 +- .../validation/profiles/RuleImplTest.java | 2 +- .../profiles/ValidationProfileImplTest.java | 8 ++--- .../validation/profiles/VariableImplTest.java | 2 +- 105 files changed, 328 insertions(+), 336 deletions(-) diff --git a/core/src/main/java/org/verapdf/component/AuditDurationImpl.java b/core/src/main/java/org/verapdf/component/AuditDurationImpl.java index 9e6c80e68..c4e45eb32 100644 --- a/core/src/main/java/org/verapdf/component/AuditDurationImpl.java +++ b/core/src/main/java/org/verapdf/component/AuditDurationImpl.java @@ -92,7 +92,7 @@ public boolean equals(Object obj) { @Override public int hashCode() { - return Objects.hash(Long.valueOf(this.start), Long.valueOf(this.finish)); + return Objects.hash(this.start, this.finish); } @Override @@ -122,8 +122,8 @@ public static String getStringDuration(final long difference) { long millis = difference % msInSec; try (Formatter formatter = new Formatter()) { - formatter.format("%02d:%02d:%02d.%03d", Long.valueOf(hours), Long.valueOf(minutes), Long.valueOf(seconds), //$NON-NLS-1$ - Long.valueOf(millis)); + formatter.format("%02d:%02d:%02d.%03d", hours, minutes, seconds, //$NON-NLS-1$ + millis); return formatter.toString(); } } diff --git a/core/src/main/java/org/verapdf/component/ComponentDetailsImpl.java b/core/src/main/java/org/verapdf/component/ComponentDetailsImpl.java index d54a0d65e..2e88bf127 100644 --- a/core/src/main/java/org/verapdf/component/ComponentDetailsImpl.java +++ b/core/src/main/java/org/verapdf/component/ComponentDetailsImpl.java @@ -36,8 +36,8 @@ */ @XmlRootElement(name = "componentDetails") class ComponentDetailsImpl implements ComponentDetails { - private final static URI defaultId = URI.create("http://component.verapdf.org#default"); - private final static ComponentDetailsImpl defaultInstance = new ComponentDetailsImpl(); + private static final URI defaultId = URI.create("http://component.verapdf.org#default"); + private static final ComponentDetailsImpl defaultInstance = new ComponentDetailsImpl(); @XmlAttribute private final URI id; @XmlAttribute diff --git a/core/src/main/java/org/verapdf/core/JAXBCollection.java b/core/src/main/java/org/verapdf/core/JAXBCollection.java index b1d799e3c..8d6adeec9 100644 --- a/core/src/main/java/org/verapdf/core/JAXBCollection.java +++ b/core/src/main/java/org/verapdf/core/JAXBCollection.java @@ -58,7 +58,7 @@ public class JAXBCollection { @XmlAnyElement (lax = true) - private List items; + private final List items; public JAXBCollection(Collection contents) { @@ -75,7 +75,7 @@ public JAXBCollection(Collection contents) public JAXBCollection() { - this(new ArrayList()); + this(new ArrayList<>()); } public List getItems() diff --git a/core/src/main/java/org/verapdf/core/MapBackedDirectory.java b/core/src/main/java/org/verapdf/core/MapBackedDirectory.java index 13ba89490..d080b937d 100644 --- a/core/src/main/java/org/verapdf/core/MapBackedDirectory.java +++ b/core/src/main/java/org/verapdf/core/MapBackedDirectory.java @@ -42,7 +42,7 @@ public class MapBackedDirectory implements Directory { * Creates an empty directory backed by an empty Map */ public MapBackedDirectory() { - this(Collections.emptyMap()); + this(Collections.emptyMap()); } /** * @param map diff --git a/core/src/main/java/org/verapdf/core/MapBackedRegistry.java b/core/src/main/java/org/verapdf/core/MapBackedRegistry.java index b6adf3da2..961e7ffdf 100644 --- a/core/src/main/java/org/verapdf/core/MapBackedRegistry.java +++ b/core/src/main/java/org/verapdf/core/MapBackedRegistry.java @@ -44,7 +44,7 @@ public class MapBackedRegistry extends MapBackedDirectory implements * Creates an empty registry instance, initialised with an empty map */ public MapBackedRegistry() { - this(new HashMap()); + this(new HashMap<>()); } /** @@ -124,8 +124,8 @@ public V updateItem(final K key, final V value) { */ @Override public void updateItems(final Map itemMap) { - for (K key : itemMap.keySet()) { - updateItem(key, itemMap.get(key)); + for (Map.Entry entry : itemMap.entrySet()) { + updateItem(entry.getKey(), entry.getValue()); } } diff --git a/core/src/main/java/org/verapdf/core/XmlSerialiser.java b/core/src/main/java/org/verapdf/core/XmlSerialiser.java index 1c8ec513c..d42f18ae3 100644 --- a/core/src/main/java/org/verapdf/core/XmlSerialiser.java +++ b/core/src/main/java/org/verapdf/core/XmlSerialiser.java @@ -397,7 +397,7 @@ protected static JAXBElement createCollectionElement(String rootName, Col private static Marshaller marshaller(JAXBContext ctx, boolean format, boolean fragment) throws JAXBException { Marshaller m = ctx.createMarshaller(); - m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.valueOf(format)); + m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, format); if (fragment) { m.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE); } diff --git a/core/src/main/java/org/verapdf/core/utils/AbstractFileOutputMapper.java b/core/src/main/java/org/verapdf/core/utils/AbstractFileOutputMapper.java index cef44f8ab..2cbc9115f 100644 --- a/core/src/main/java/org/verapdf/core/utils/AbstractFileOutputMapper.java +++ b/core/src/main/java/org/verapdf/core/utils/AbstractFileOutputMapper.java @@ -72,7 +72,7 @@ public File mapFile(final File orig) throws VeraPDFException { return doMapFile(orig); } - abstract protected File doMapFile(final File orig) throws VeraPDFException; + protected abstract File doMapFile(final File orig) throws VeraPDFException; protected static String addPrefixAndSuffix(final File orig, final FileOutputMapper mapper) { if (orig == null) diff --git a/core/src/main/java/org/verapdf/core/utils/RelativeDirectoryMapper.java b/core/src/main/java/org/verapdf/core/utils/RelativeDirectoryMapper.java index 51bfecf74..9683044cf 100644 --- a/core/src/main/java/org/verapdf/core/utils/RelativeDirectoryMapper.java +++ b/core/src/main/java/org/verapdf/core/utils/RelativeDirectoryMapper.java @@ -36,7 +36,7 @@ final class RelativeDirectoryMapper extends AbstractFileOutputMapper { static final String defaultRelativePath = "."; - private final static RelativeDirectoryMapper defaultInstance = new RelativeDirectoryMapper(); + private static final RelativeDirectoryMapper defaultInstance = new RelativeDirectoryMapper(); private final String relDirPath; private RelativeDirectoryMapper() { diff --git a/core/src/main/java/org/verapdf/core/utils/VersioningMapper.java b/core/src/main/java/org/verapdf/core/utils/VersioningMapper.java index f21d44261..0be0f97ba 100644 --- a/core/src/main/java/org/verapdf/core/utils/VersioningMapper.java +++ b/core/src/main/java/org/verapdf/core/utils/VersioningMapper.java @@ -35,9 +35,9 @@ */ final class VersioningMapper implements FileOutputMapper { - private final static String verPrefixOpen = "_("; //$NON-NLS-1$ - private final static String verPrefixClose = ")"; //$NON-NLS-1$ - final static VersioningMapper defaultInstance = new VersioningMapper(); + private static final String verPrefixOpen = "_("; //$NON-NLS-1$ + private static final String verPrefixClose = ")"; //$NON-NLS-1$ + static final VersioningMapper defaultInstance = new VersioningMapper(); protected final FileOutputMapper mapper; private VersioningMapper() { @@ -75,9 +75,9 @@ private static File newVersion(final File orig) { int maxVersion = -1; for (File version : getVersions(orig)) { int vers = getVersion(orig, version); - maxVersion = (vers > maxVersion) ? vers : maxVersion; + maxVersion = Math.max(vers, maxVersion); } - Integer version = Integer.valueOf(maxVersion + 1); + Integer version = maxVersion + 1; String versionedName = String.format("%s%d%s", verStart(orig), version, verEnd(orig)); //$NON-NLS-1$ return new File(orig.getParentFile(), versionedName); } diff --git a/core/src/main/java/org/verapdf/features/AbstractFeaturesExtractor.java b/core/src/main/java/org/verapdf/features/AbstractFeaturesExtractor.java index ee7fab2b7..0711c50d6 100644 --- a/core/src/main/java/org/verapdf/features/AbstractFeaturesExtractor.java +++ b/core/src/main/java/org/verapdf/features/AbstractFeaturesExtractor.java @@ -42,7 +42,7 @@ public abstract class AbstractFeaturesExtractor { } public final void initialize(ExtractorDetails initialDetails) { - initialize(initialDetails, Collections.emptyMap()); + initialize(initialDetails, Collections.emptyMap()); } public final void initialize(ExtractorDetails initialDetails, Map initialAttributes) { diff --git a/core/src/main/java/org/verapdf/features/FeatureExtractionResult.java b/core/src/main/java/org/verapdf/features/FeatureExtractionResult.java index 47c717130..e2ae58cfe 100644 --- a/core/src/main/java/org/verapdf/features/FeatureExtractionResult.java +++ b/core/src/main/java/org/verapdf/features/FeatureExtractionResult.java @@ -67,7 +67,7 @@ public void addNewFeatureTree(FeatureObjectType type, FeatureTreeNode root) { */ public List getFeatureTreesForType(FeatureObjectType type) { FeaturesStructure list = this.collection.get(type); - return (list == null || list.list == null) ? Collections.emptyList() : list.list; + return (list == null || list.list == null) ? Collections.emptyList() : list.list; } /** @@ -97,10 +97,10 @@ public void addNewError(FeatureObjectType type, String errorID) { */ public List getErrorsForType(FeatureObjectType type) { FeaturesStructure list = this.collection.get(type); - return (list == null || list.errors == null) ? Collections.emptyList() : list.errors; + return (list == null || list.errors == null) ? Collections.emptyList() : list.errors; } - private class FeaturesStructure { + private static class FeaturesStructure { List list; List errors; @@ -116,8 +116,8 @@ public boolean equals(Object o) { FeaturesStructure that = (FeaturesStructure) o; - if (list != null ? !list.equals(that.list) : that.list != null) return false; - return errors != null ? errors.equals(that.errors) : that.errors == null; + if (!Objects.equals(list, that.list)) return false; + return Objects.equals(errors, that.errors); } @@ -136,7 +136,7 @@ public boolean equals(Object o) { FeatureExtractionResult that = (FeatureExtractionResult) o; - return collection != null ? collection.equals(that.collection) : that.collection == null; + return Objects.equals(collection, that.collection); } diff --git a/core/src/main/java/org/verapdf/features/FeaturesReporter.java b/core/src/main/java/org/verapdf/features/FeaturesReporter.java index 4266d0117..e2c67d892 100644 --- a/core/src/main/java/org/verapdf/features/FeaturesReporter.java +++ b/core/src/main/java/org/verapdf/features/FeaturesReporter.java @@ -64,7 +64,7 @@ public FeaturesReporter(FeatureExtractorConfig config, ListemptyList()); + this(config, Collections.emptyList()); } /** @@ -73,11 +73,7 @@ public FeaturesReporter(FeatureExtractorConfig config) { * @param extractor object for extract custom features */ private void registerFeaturesExtractor(AbstractFeaturesExtractor extractor) { - if (featuresExtractors.get(extractor.getType()) == null) { - featuresExtractors.put(extractor.getType(), new ArrayList()); - } - - featuresExtractors.get(extractor.getType()).add(extractor); + featuresExtractors.computeIfAbsent(extractor.getType(), k -> new ArrayList<>()).add(extractor); } /** @@ -127,13 +123,13 @@ public void report(FeaturesObject obj) { } } - } catch (FeatureParsingException ignore) { + } catch (FeatureParsingException exception) { // The method logic should ensure this never happens, so if it does // it's catastrophic. We'll throw an IllegalStateException with this // as a cause. The only time it's ignored is when the unthinkable // happens throw new IllegalStateException( - "FeaturesReporter.report() illegal state.", ignore); + "FeaturesReporter.report() illegal state.", exception); // This exception occurs when wrong node creates for feature tree. // The logic of the method guarantees this doesn't occur. } diff --git a/core/src/main/java/org/verapdf/features/FontFeaturesData.java b/core/src/main/java/org/verapdf/features/FontFeaturesData.java index 2092f398d..b279ee040 100644 --- a/core/src/main/java/org/verapdf/features/FontFeaturesData.java +++ b/core/src/main/java/org/verapdf/features/FontFeaturesData.java @@ -258,14 +258,14 @@ public static final class Builder { private Double italicAngle = null; private Double ascent = null; private Double descent = null; - private Double leading = Double.valueOf(0.); + private Double leading = 0.; private Double capHeight = null; - private Double xHeight = Double.valueOf(0.); + private Double xHeight = 0.; private Double stemV = null; - private Double stemH = Double.valueOf(0.); - private Double avgWidth = Double.valueOf(0.); - private Double maxWidth = Double.valueOf(0.); - private Double missingWidth = Double.valueOf(0.); + private Double stemH = 0.; + private Double avgWidth = 0.; + private Double maxWidth = 0.; + private Double missingWidth = 0.; private String charSet = null; public Builder(InputStream stream) { @@ -340,7 +340,7 @@ public Builder leading(Double leading) { if (leading != null) { this.leading = leading; } else { - this.leading = Double.valueOf(0.0); + this.leading = 0.0; } return this; } @@ -354,7 +354,7 @@ public Builder xHeight(Double xHeight) { if (xHeight != null) { this.xHeight = xHeight; } else { - this.xHeight = Double.valueOf(0.0); + this.xHeight = 0.0; } return this; } @@ -368,7 +368,7 @@ public Builder stemH(Double stemH) { if (stemH != null) { this.stemH = stemH; } else { - this.stemH = Double.valueOf(0.0); + this.stemH = 0.0; } return this; } @@ -377,7 +377,7 @@ public Builder avgWidth(Double avgWidth) { if (avgWidth != null) { this.avgWidth = avgWidth; } else { - this.avgWidth = Double.valueOf(0.0); + this.avgWidth = 0.0; } return this; } @@ -386,7 +386,7 @@ public Builder maxWidth(Double maxWidth) { if (maxWidth != null) { this.maxWidth = maxWidth; } else { - this.maxWidth = Double.valueOf(0.0); + this.maxWidth = 0.0; } return this; } @@ -395,7 +395,7 @@ public Builder missingWidth(Double missingWidth) { if (missingWidth != null) { this.missingWidth = missingWidth; } else { - this.missingWidth = Double.valueOf(0.0); + this.missingWidth = 0.0; } return this; } diff --git a/core/src/main/java/org/verapdf/features/ImageFeaturesData.java b/core/src/main/java/org/verapdf/features/ImageFeaturesData.java index 05c9eee82..6322c10ba 100644 --- a/core/src/main/java/org/verapdf/features/ImageFeaturesData.java +++ b/core/src/main/java/org/verapdf/features/ImageFeaturesData.java @@ -135,7 +135,7 @@ public static class Filter implements Closeable { Filter(String name, Map properties, InputStream stream) { this.name = name; - this.properties = properties == null ? new HashMap() : new HashMap<>(properties); + this.properties = properties == null ? new HashMap<>() : new HashMap<>(properties); this.stream = stream; } diff --git a/core/src/main/java/org/verapdf/features/SignatureFeaturesData.java b/core/src/main/java/org/verapdf/features/SignatureFeaturesData.java index 7c498c92f..38c5ee635 100644 --- a/core/src/main/java/org/verapdf/features/SignatureFeaturesData.java +++ b/core/src/main/java/org/verapdf/features/SignatureFeaturesData.java @@ -28,13 +28,13 @@ */ public class SignatureFeaturesData extends FeaturesData { - private String filter; - private String subFilter; - private String name; - private Calendar signDate; - private String location; - private String reason; - private String contactInfo; + private final String filter; + private final String subFilter; + private final String name; + private final Calendar signDate; + private final String location; + private final String reason; + private final String contactInfo; public SignatureFeaturesData(InputStream stream, String filter, String subFilter, String name, Calendar signDate, String location, String reason, String contactInfo) { super(stream); diff --git a/core/src/main/java/org/verapdf/features/objects/EmbeddedFileFeaturesObject.java b/core/src/main/java/org/verapdf/features/objects/EmbeddedFileFeaturesObject.java index 9d69171f5..85036c310 100644 --- a/core/src/main/java/org/verapdf/features/objects/EmbeddedFileFeaturesObject.java +++ b/core/src/main/java/org/verapdf/features/objects/EmbeddedFileFeaturesObject.java @@ -120,7 +120,7 @@ public FeaturesData getData() { builder.checkSum(efAdapter.getCheckSum()); Long size = efAdapter.getSize(); if (size != null) { - builder.size(Integer.valueOf(size.intValue())); + builder.size(size.intValue()); } return builder.build(); } diff --git a/core/src/main/java/org/verapdf/features/objects/Feature.java b/core/src/main/java/org/verapdf/features/objects/Feature.java index d7517aee4..c9ae5a452 100644 --- a/core/src/main/java/org/verapdf/features/objects/Feature.java +++ b/core/src/main/java/org/verapdf/features/objects/Feature.java @@ -73,7 +73,7 @@ public enum FeatureType { STRING(PRESENT, NOT_PRESENT, IS_EQUAL, NOT_EQUAL, STARTS_WITH, /*ENDS_WITH,*/ CONTAINS); - private EnumSet legalOperations; + private final EnumSet legalOperations; FeatureType(SchematronOperation op, SchematronOperation... operations) { this.legalOperations = EnumSet.of(op, operations); diff --git a/core/src/main/java/org/verapdf/features/objects/FeaturesObject.java b/core/src/main/java/org/verapdf/features/objects/FeaturesObject.java index 2765f9dee..b01f16a43 100644 --- a/core/src/main/java/org/verapdf/features/objects/FeaturesObject.java +++ b/core/src/main/java/org/verapdf/features/objects/FeaturesObject.java @@ -37,7 +37,7 @@ */ public abstract class FeaturesObject { - protected FeaturesObjectAdapter adapter; + protected final FeaturesObjectAdapter adapter; protected final List errors = new ArrayList<>(); FeaturesObject(FeaturesObjectAdapter adapter) { diff --git a/core/src/main/java/org/verapdf/features/objects/FeaturesStructureContainer.java b/core/src/main/java/org/verapdf/features/objects/FeaturesStructureContainer.java index d78fd3c64..418a2d42a 100644 --- a/core/src/main/java/org/verapdf/features/objects/FeaturesStructureContainer.java +++ b/core/src/main/java/org/verapdf/features/objects/FeaturesStructureContainer.java @@ -31,7 +31,7 @@ * @author Maksim Bezrukov */ public final class FeaturesStructureContainer { - private static Map> featuresStructure = + private static final Map> featuresStructure = new EnumMap<>(FeatureObjectType.class); static { @@ -64,6 +64,6 @@ private FeaturesStructureContainer() { public static List getFeaturesListForType(FeatureObjectType type) { List res = featuresStructure.get(type); - return res == null ? Collections.emptyList() : Collections.unmodifiableList(res); + return res == null ? Collections.emptyList() : Collections.unmodifiableList(res); } } diff --git a/core/src/main/java/org/verapdf/features/objects/FontFeaturesObject.java b/core/src/main/java/org/verapdf/features/objects/FontFeaturesObject.java index dad947aef..5794c05a5 100644 --- a/core/src/main/java/org/verapdf/features/objects/FontFeaturesObject.java +++ b/core/src/main/java/org/verapdf/features/objects/FontFeaturesObject.java @@ -133,11 +133,11 @@ public FeatureTreeNode collectFeatures() throws FeatureParsingException { TYPE3.equals(fontType)) { Long fc = fontAdapter.getFirstChar(); - if (fc != null && fc.longValue() != -1) { + if (fc != null && fc != -1) { root.addChild("firstChar").setValue(String.valueOf(fc.longValue())); } Long lc = fontAdapter.getLastChar(); - if (lc != null && lc.longValue() != -1) { + if (lc != null && lc != -1) { root.addChild("lastChar").setValue(String.valueOf(lc.longValue())); } @@ -197,8 +197,8 @@ public FeaturesData getData() { double[] rex = descriptor.getFontBoundingBox(); if (rex != null) { List rect = new ArrayList<>(rex.length); - for (int i = 0; i < rex.length; ++i) { - rect.add(rex[i]); + for (double v : rex) { + rect.add(v); } builder.fontBBox(rect); } @@ -297,7 +297,7 @@ private void parseFontDescriptior(FontFeaturesObjectAdapter.FontDescriptorAdapte actualFontName = ""; } boolean subset = actualFontName.matches("^[A-Z]{6}\\+.*"); - String fontName = subset ? actualFontName.substring(7, actualFontName.length()) : actualFontName; + String fontName = subset ? actualFontName.substring(7) : actualFontName; CreateNodeHelper.addNotEmptyNode(SUBSET, String.valueOf(subset), descriptorNode); CreateNodeHelper.addNotEmptyNode(FONT_NAME, fontName, descriptorNode); CreateNodeHelper.addNotEmptyNode(FONT_FAMILY, descriptor.getFontFamily(), descriptorNode); diff --git a/core/src/main/java/org/verapdf/features/objects/ImageXObjectFeaturesObject.java b/core/src/main/java/org/verapdf/features/objects/ImageXObjectFeaturesObject.java index e307c6869..94e51581f 100644 --- a/core/src/main/java/org/verapdf/features/objects/ImageXObjectFeaturesObject.java +++ b/core/src/main/java/org/verapdf/features/objects/ImageXObjectFeaturesObject.java @@ -182,7 +182,7 @@ public FeaturesData getData() { resFilters.add(ImageFeaturesData.Filter.newInstance(filterNameValue, getDCTFiltersMap(adapter), null)); break; case "JBIG2Decode": - resFilters.add(ImageFeaturesData.Filter.newInstance(filterNameValue, new HashMap(), + resFilters.add(ImageFeaturesData.Filter.newInstance(filterNameValue, new HashMap<>(), adapter.getJBIG2Global())); break; case "Crypt": @@ -193,7 +193,7 @@ public FeaturesData getData() { //$FALL-THROUGH$ default: resFilters.add( - ImageFeaturesData.Filter.newInstance(filterNameValue, new HashMap(), null)); + ImageFeaturesData.Filter.newInstance(filterNameValue, new HashMap<>(), null)); } } } @@ -209,18 +209,17 @@ private static Map getCCITTFaxFiltersMap( ImageXObjectFeaturesObjectAdapter.StreamFilterAdapter filter) { Map res = new HashMap<>(); if (filter != null) { - putIntegerAsStringWithDefault(res, "K", filter.getCCITTK(), Integer.valueOf(0)); + putIntegerAsStringWithDefault(res, "K", filter.getCCITTK(), 0); putBooleanAsStringWithDefault(res, "EndOfLine", filter.getCCITTEndOfLine(), Boolean.FALSE); putBooleanAsStringWithDefault(res, "EncodedByteAlign", filter.getCCITTEncodedByteAlign(), Boolean.FALSE); - putIntegerAsStringWithDefault(res, "Columns", filter.getCCITTColumns(), - Integer.valueOf(1728)); - putIntegerAsStringWithDefault(res, "Rows", filter.getCCITTRows(), Integer.valueOf(0)); + putIntegerAsStringWithDefault(res, "Columns", filter.getCCITTColumns(), 1728); + putIntegerAsStringWithDefault(res, "Rows", filter.getCCITTRows(), 0); putBooleanAsStringWithDefault(res, "EndOfBlock", filter.getCCITTEndOfBlock(), Boolean.TRUE); putBooleanAsStringWithDefault(res, "BlackIs1", filter.getCCITTBlackIs1(), Boolean.FALSE); putIntegerAsStringWithDefault(res, "DamagedRowsBeforeError", - filter.getCCITTDamagedRowsBeforeError(), Integer.valueOf(0)); + filter.getCCITTDamagedRowsBeforeError(), 0); } else { res.put("K", "0"); res.put("EndOfLine", "false"); @@ -256,8 +255,7 @@ private static Map createLZWFilterMap( } Map retVal = createFlatFilterMap(filter); - putIntegerAsStringWithDefault(retVal, "EarlyChange", filter.getLZWEarlyChange(), - Integer.valueOf(1)); + putIntegerAsStringWithDefault(retVal, "EarlyChange", filter.getLZWEarlyChange(), 1); return retVal; } @@ -270,12 +268,10 @@ private static Map createFlatFilterMap( Map res = new HashMap<>(); - putIntegerAsStringWithDefault(res, "Predictor", filter.getFlatePredictor(), - Integer.valueOf(1)); - putIntegerAsStringWithDefault(res, "Colors", filter.getFlateColors(), Integer.valueOf(1)); - putIntegerAsStringWithDefault(res, "BitsPerComponent", filter.getFlateBitsPerComponent(), - Integer.valueOf(8)); - putIntegerAsStringWithDefault(res, "Columns", filter.getFlateColumns(), Integer.valueOf(1)); + putIntegerAsStringWithDefault(res, "Predictor", filter.getFlatePredictor(), 1); + putIntegerAsStringWithDefault(res, "Colors", filter.getFlateColors(), 1); + putIntegerAsStringWithDefault(res, "BitsPerComponent", filter.getFlateBitsPerComponent(), 8); + putIntegerAsStringWithDefault(res, "Columns", filter.getFlateColumns(), 1); return res; } @@ -290,7 +286,7 @@ private static Map createDefaultFlatFilterMap() { private static Integer getIntegerWithDefault(Long value, Integer defaultValue) { if (value != null) { - return Integer.valueOf(value.intValue()); + return value.intValue(); } return defaultValue; } diff --git a/core/src/main/java/org/verapdf/features/objects/LowLvlInfoFeaturesObject.java b/core/src/main/java/org/verapdf/features/objects/LowLvlInfoFeaturesObject.java index da3f5611c..94dece4df 100644 --- a/core/src/main/java/org/verapdf/features/objects/LowLvlInfoFeaturesObject.java +++ b/core/src/main/java/org/verapdf/features/objects/LowLvlInfoFeaturesObject.java @@ -122,7 +122,7 @@ private String getPDFVersionString(LowLvlInfoFeaturesObjectAdapter lowLvlAdapter String catalogVersion = lowLvlAdapter.getCatalogVersion(); if (catalogVersion != null) { try { - double catalogValue = Double.valueOf(catalogVersion); + double catalogValue = Double.parseDouble(catalogVersion); res = Math.max(res, catalogValue); } catch (NumberFormatException e) { LOGGER.log(Level.FINE, "Problems in obtaining pdf version number from the catalog", e); diff --git a/core/src/main/java/org/verapdf/features/tools/ErrorsHelper.java b/core/src/main/java/org/verapdf/features/tools/ErrorsHelper.java index 1c84e2668..3ce02574e 100644 --- a/core/src/main/java/org/verapdf/features/tools/ErrorsHelper.java +++ b/core/src/main/java/org/verapdf/features/tools/ErrorsHelper.java @@ -86,12 +86,12 @@ public static String addErrorIntoCollection(FeatureExtractionResult collection, element.setAttribute(ERRORID, elementErrorID); } return id; - } catch (FeatureParsingException ignore) { + } catch (FeatureParsingException exception) { // This exception occurs when wrong node creates for feature tree. // The logic of the method guarantees this doesn't occur. String message = "FeatureTreeNode root instance logic failure"; - LOGGER.log(Level.SEVERE, message, ignore); - throw new IllegalStateException(message, ignore); + LOGGER.log(Level.SEVERE, message, exception); + throw new IllegalStateException(message, exception); } } } diff --git a/core/src/main/java/org/verapdf/features/tools/FeatureTreeNode.java b/core/src/main/java/org/verapdf/features/tools/FeatureTreeNode.java index 39a35e418..17364c646 100644 --- a/core/src/main/java/org/verapdf/features/tools/FeatureTreeNode.java +++ b/core/src/main/java/org/verapdf/features/tools/FeatureTreeNode.java @@ -34,8 +34,8 @@ public final class FeatureTreeNode { private final String name; private final boolean isMetadataNode; private String value; - private Map attributes = new HashMap<>(); - private List children = new ArrayList<>(); + private final Map attributes = new HashMap<>(); + private final List children = new ArrayList<>(); private FeatureTreeNode(String name) { this(name, false); @@ -223,7 +223,6 @@ public String toString() { } private static boolean isChildrenMatch(FeatureTreeNode aThis, FeatureTreeNode other) { - return aThis.children == other.children || ((aThis.children == null) == (other.children == null)) - && aThis.children.size() == other.children.size() && aThis.children.containsAll(other.children); + return Objects.equals(aThis.children, other.children); } } diff --git a/core/src/main/java/org/verapdf/metadata/fixer/FixerConfigImpl.java b/core/src/main/java/org/verapdf/metadata/fixer/FixerConfigImpl.java index a934b5d5a..7f806ebb7 100644 --- a/core/src/main/java/org/verapdf/metadata/fixer/FixerConfigImpl.java +++ b/core/src/main/java/org/verapdf/metadata/fixer/FixerConfigImpl.java @@ -29,8 +29,8 @@ */ @XmlRootElement(name = "fixerConfig") final class FixerConfigImpl implements MetadataFixerConfig { - public final static String DEFAULT_PREFIX = "veraFixMd_"; //$NON-NLS-1$ - private final static MetadataFixerConfig defaultInstance = new FixerConfigImpl(); + public static final String DEFAULT_PREFIX = "veraFixMd_"; //$NON-NLS-1$ + private static final MetadataFixerConfig defaultInstance = new FixerConfigImpl(); @XmlAttribute private final String fixesPrefix; diff --git a/core/src/main/java/org/verapdf/metadata/fixer/utils/parser/XMLProcessedObjectsParser.java b/core/src/main/java/org/verapdf/metadata/fixer/utils/parser/XMLProcessedObjectsParser.java index 76d1fb63f..ec84c375b 100644 --- a/core/src/main/java/org/verapdf/metadata/fixer/utils/parser/XMLProcessedObjectsParser.java +++ b/core/src/main/java/org/verapdf/metadata/fixer/utils/parser/XMLProcessedObjectsParser.java @@ -50,7 +50,7 @@ public class XMLProcessedObjectsParser implements ProcessedObjectsParser { private static final String XML_PROCESSED_OBJECTS_PATH_PROPERTY_PDFUA_1 = "processed.objects.path.pdfua_1"; private static final String XML_PROCESSED_OBJECTS_PATH_PROPERTY_PDFUA_2 = "processed.objects.path.pdfua_2"; - private static ClassLoader cl = XMLProcessedObjectsParser.class.getClassLoader(); + private static final ClassLoader cl = XMLProcessedObjectsParser.class.getClassLoader(); private static ProcessedObjectsParser instance; private XMLProcessedObjectsParser() { diff --git a/core/src/main/java/org/verapdf/model/impl/axl/AXLExtensionSchemaDefinition.java b/core/src/main/java/org/verapdf/model/impl/axl/AXLExtensionSchemaDefinition.java index 7402333ec..647033e68 100644 --- a/core/src/main/java/org/verapdf/model/impl/axl/AXLExtensionSchemaDefinition.java +++ b/core/src/main/java/org/verapdf/model/impl/axl/AXLExtensionSchemaDefinition.java @@ -107,7 +107,7 @@ private List getExtensionSchemaProperties() { public Boolean getisNamespaceURIValidURI() { for (VeraPDFXMPNode child : this.xmpNode.getChildren()) { if (XMPConst.NS_PDFA_SCHEMA.equals(child.getNamespaceURI()) && NAMESPACE_URI.equals(child.getName())) { - return Boolean.valueOf(new URITypeValidator().isCorresponding(child)); + return new URITypeValidator().isCorresponding(child); } } return Boolean.TRUE; @@ -117,7 +117,7 @@ public Boolean getisNamespaceURIValidURI() { public Boolean getisPrefixValidText() { for (VeraPDFXMPNode child : this.xmpNode.getChildren()) { if (XMPConst.NS_PDFA_SCHEMA.equals(child.getNamespaceURI()) && PREFIX.equals(child.getName())) { - return Boolean.valueOf(SimpleTypeValidator.fromValue(SimpleTypeValidator.SimpleTypeEnum.TEXT).isCorresponding(child)); + return SimpleTypeValidator.fromValue(SimpleTypeValidator.SimpleTypeEnum.TEXT).isCorresponding(child); } } return Boolean.TRUE; @@ -127,7 +127,7 @@ public Boolean getisPrefixValidText() { public Boolean getisPropertyValidSeq() { for (VeraPDFXMPNode child : this.xmpNode.getChildren()) { if (XMPConst.NS_PDFA_SCHEMA.equals(child.getNamespaceURI()) && PROPERTY.equals(child.getName())) { - return Boolean.valueOf(child.getOptions().isArrayOrdered()); + return child.getOptions().isArrayOrdered(); } } return Boolean.TRUE; @@ -137,7 +137,7 @@ public Boolean getisPropertyValidSeq() { public Boolean getisSchemaValidText() { for (VeraPDFXMPNode child : this.xmpNode.getChildren()) { if (XMPConst.NS_PDFA_SCHEMA.equals(child.getNamespaceURI()) && SCHEMA.equals(child.getName())) { - return Boolean.valueOf(SimpleTypeValidator.fromValue(SimpleTypeValidator.SimpleTypeEnum.TEXT).isCorresponding(child)); + return SimpleTypeValidator.fromValue(SimpleTypeValidator.SimpleTypeEnum.TEXT).isCorresponding(child); } } return Boolean.TRUE; @@ -147,7 +147,7 @@ public Boolean getisSchemaValidText() { public Boolean getisValueTypeValidSeq() { for (VeraPDFXMPNode child : this.xmpNode.getChildren()) { if (XMPConst.NS_PDFA_SCHEMA.equals(child.getNamespaceURI()) && VALUE_TYPE.equals(child.getName())) { - return Boolean.valueOf(child.getOptions().isArrayOrdered()); + return child.getOptions().isArrayOrdered(); } } return Boolean.TRUE; @@ -203,10 +203,12 @@ public String getvalueTypePrefix() { return null; } + @Override protected String getValidNamespaceURI() { return XMPConst.NS_PDFA_SCHEMA; } + @Override protected Set getValidChildNames() { return validChildNames; } diff --git a/core/src/main/java/org/verapdf/model/impl/axl/AXLExtensionSchemaField.java b/core/src/main/java/org/verapdf/model/impl/axl/AXLExtensionSchemaField.java index 3f3f06021..10bff6532 100644 --- a/core/src/main/java/org/verapdf/model/impl/axl/AXLExtensionSchemaField.java +++ b/core/src/main/java/org/verapdf/model/impl/axl/AXLExtensionSchemaField.java @@ -49,7 +49,7 @@ public AXLExtensionSchemaField(VeraPDFXMPNode xmpNode, ValidatorsContainer conta public Boolean getisDescriptionValidText() { for (VeraPDFXMPNode child : this.xmpNode.getChildren()) { if (XMPConst.NS_PDFA_FIELD.equals(child.getNamespaceURI()) && DESCRIPTION.equals(child.getName())) { - return Boolean.valueOf(SimpleTypeValidator.fromValue(SimpleTypeValidator.SimpleTypeEnum.TEXT).isCorresponding(child)); + return SimpleTypeValidator.fromValue(SimpleTypeValidator.SimpleTypeEnum.TEXT).isCorresponding(child); } } return Boolean.TRUE; @@ -59,7 +59,7 @@ public Boolean getisDescriptionValidText() { public Boolean getisNameValidText() { for (VeraPDFXMPNode child : this.xmpNode.getChildren()) { if (XMPConst.NS_PDFA_FIELD.equals(child.getNamespaceURI()) && NAME.equals(child.getName())) { - return Boolean.valueOf(SimpleTypeValidator.fromValue(SimpleTypeValidator.SimpleTypeEnum.TEXT).isCorresponding(child)); + return SimpleTypeValidator.fromValue(SimpleTypeValidator.SimpleTypeEnum.TEXT).isCorresponding(child); } } return Boolean.TRUE; @@ -69,7 +69,7 @@ public Boolean getisNameValidText() { public Boolean getisValueTypeValidText() { for (VeraPDFXMPNode child : this.xmpNode.getChildren()) { if (XMPConst.NS_PDFA_FIELD.equals(child.getNamespaceURI()) && VALUE_TYPE.equals(child.getName())) { - return Boolean.valueOf(SimpleTypeValidator.fromValue(SimpleTypeValidator.SimpleTypeEnum.TEXT).isCorresponding(child)); + return SimpleTypeValidator.fromValue(SimpleTypeValidator.SimpleTypeEnum.TEXT).isCorresponding(child); } } return Boolean.TRUE; @@ -86,7 +86,7 @@ public Boolean getisValueTypeDefined() { private Boolean isValueTypeValidForPDFA_1() { for (VeraPDFXMPNode child : this.xmpNode.getChildren()) { if (XMPConst.NS_PDFA_FIELD.equals(child.getNamespaceURI()) && VALUE_TYPE.equals(child.getName())) { - return Boolean.valueOf(this.containerForPDFA_1.isKnownType(child.getValue())); + return this.containerForPDFA_1.isKnownType(child.getValue()); } } return Boolean.TRUE; @@ -95,7 +95,7 @@ private Boolean isValueTypeValidForPDFA_1() { private Boolean isValueTypeValidForPDFA_2_3() { for (VeraPDFXMPNode child : this.xmpNode.getChildren()) { if (XMPConst.NS_PDFA_FIELD.equals(child.getNamespaceURI()) && VALUE_TYPE.equals(child.getName())) { - return Boolean.valueOf(this.containerForPDFA_2_3.isKnownType(child.getValue())); + return this.containerForPDFA_2_3.isKnownType(child.getValue()); } } return Boolean.TRUE; @@ -131,10 +131,12 @@ public String getvalueTypePrefix() { return null; } + @Override protected String getValidNamespaceURI() { return XMPConst.NS_PDFA_FIELD; } + @Override protected Set getValidChildNames() { return validChildNames; } diff --git a/core/src/main/java/org/verapdf/model/impl/axl/AXLExtensionSchemaObject.java b/core/src/main/java/org/verapdf/model/impl/axl/AXLExtensionSchemaObject.java index 0b29fe083..c2c05c96d 100644 --- a/core/src/main/java/org/verapdf/model/impl/axl/AXLExtensionSchemaObject.java +++ b/core/src/main/java/org/verapdf/model/impl/axl/AXLExtensionSchemaObject.java @@ -34,7 +34,7 @@ */ public abstract class AXLExtensionSchemaObject extends AXLXMPObject implements ExtensionSchemaObject { - protected VeraPDFXMPNode xmpNode; + protected final VeraPDFXMPNode xmpNode; protected final ValidatorsContainer containerForPDFA_1; protected final ValidatorsContainer containerForPDFA_2_3; protected final PDFAFlavour flavour; diff --git a/core/src/main/java/org/verapdf/model/impl/axl/AXLExtensionSchemaProperty.java b/core/src/main/java/org/verapdf/model/impl/axl/AXLExtensionSchemaProperty.java index 42fe5e6c8..58ed0e096 100644 --- a/core/src/main/java/org/verapdf/model/impl/axl/AXLExtensionSchemaProperty.java +++ b/core/src/main/java/org/verapdf/model/impl/axl/AXLExtensionSchemaProperty.java @@ -60,7 +60,7 @@ public String getcategory() { public Boolean getisCategoryValidText() { for (VeraPDFXMPNode child : this.xmpNode.getChildren()) { if (XMPConst.NS_PDFA_PROPERTY.equals(child.getNamespaceURI()) && CATEGORY.equals(child.getName())) { - return Boolean.valueOf(SimpleTypeValidator.fromValue(SimpleTypeValidator.SimpleTypeEnum.TEXT).isCorresponding(child)); + return SimpleTypeValidator.fromValue(SimpleTypeValidator.SimpleTypeEnum.TEXT).isCorresponding(child); } } return Boolean.TRUE; @@ -70,7 +70,7 @@ public Boolean getisCategoryValidText() { public Boolean getisDescriptionValidText() { for (VeraPDFXMPNode child : this.xmpNode.getChildren()) { if (XMPConst.NS_PDFA_PROPERTY.equals(child.getNamespaceURI()) && DESCRIPTION.equals(child.getName())) { - return Boolean.valueOf(SimpleTypeValidator.fromValue(SimpleTypeValidator.SimpleTypeEnum.TEXT).isCorresponding(child)); + return SimpleTypeValidator.fromValue(SimpleTypeValidator.SimpleTypeEnum.TEXT).isCorresponding(child); } } return Boolean.TRUE; @@ -80,7 +80,7 @@ public Boolean getisDescriptionValidText() { public Boolean getisNameValidText() { for (VeraPDFXMPNode child : this.xmpNode.getChildren()) { if (XMPConst.NS_PDFA_PROPERTY.equals(child.getNamespaceURI()) && NAME.equals(child.getName())) { - return Boolean.valueOf(SimpleTypeValidator.fromValue(SimpleTypeValidator.SimpleTypeEnum.TEXT).isCorresponding(child)); + return SimpleTypeValidator.fromValue(SimpleTypeValidator.SimpleTypeEnum.TEXT).isCorresponding(child); } } return Boolean.TRUE; @@ -90,7 +90,7 @@ public Boolean getisNameValidText() { public Boolean getisValueTypeValidText() { for (VeraPDFXMPNode child : this.xmpNode.getChildren()) { if (XMPConst.NS_PDFA_PROPERTY.equals(child.getNamespaceURI()) && VALUE_TYPE.equals(child.getName())) { - return Boolean.valueOf(SimpleTypeValidator.fromValue(SimpleTypeValidator.SimpleTypeEnum.TEXT).isCorresponding(child)); + return SimpleTypeValidator.fromValue(SimpleTypeValidator.SimpleTypeEnum.TEXT).isCorresponding(child); } } return Boolean.TRUE; @@ -107,7 +107,7 @@ public Boolean getisValueTypeDefined() { private Boolean isValueTypeValidForPDFA_1() { for (VeraPDFXMPNode child : this.xmpNode.getChildren()) { if (XMPConst.NS_PDFA_PROPERTY.equals(child.getNamespaceURI()) && VALUE_TYPE.equals(child.getName())) { - return Boolean.valueOf(this.containerForPDFA_1.isKnownType(child.getValue())); + return this.containerForPDFA_1.isKnownType(child.getValue()); } } return Boolean.TRUE; @@ -116,7 +116,7 @@ private Boolean isValueTypeValidForPDFA_1() { private Boolean isValueTypeValidForPDFA_2_3() { for (VeraPDFXMPNode child : this.xmpNode.getChildren()) { if (XMPConst.NS_PDFA_PROPERTY.equals(child.getNamespaceURI()) && VALUE_TYPE.equals(child.getName())) { - return Boolean.valueOf(this.containerForPDFA_2_3.isKnownType(child.getValue())); + return this.containerForPDFA_2_3.isKnownType(child.getValue()); } } return Boolean.TRUE; @@ -162,10 +162,12 @@ public String getvalueTypePrefix() { return null; } + @Override protected String getValidNamespaceURI() { return XMPConst.NS_PDFA_PROPERTY; } + @Override protected Set getValidChildNames() { return validChildNames; } diff --git a/core/src/main/java/org/verapdf/model/impl/axl/AXLExtensionSchemaValueType.java b/core/src/main/java/org/verapdf/model/impl/axl/AXLExtensionSchemaValueType.java index e743a52c9..df0a6c1f7 100644 --- a/core/src/main/java/org/verapdf/model/impl/axl/AXLExtensionSchemaValueType.java +++ b/core/src/main/java/org/verapdf/model/impl/axl/AXLExtensionSchemaValueType.java @@ -87,7 +87,7 @@ private List getExtensionSchemaFields() { public Boolean getisDescriptionValidText() { for (VeraPDFXMPNode child : this.xmpNode.getChildren()) { if (XMPConst.NS_PDFA_TYPE.equals(child.getNamespaceURI()) && DESCRIPTION.equals(child.getName())) { - return Boolean.valueOf(SimpleTypeValidator.fromValue(SimpleTypeValidator.SimpleTypeEnum.TEXT).isCorresponding(child)); + return SimpleTypeValidator.fromValue(SimpleTypeValidator.SimpleTypeEnum.TEXT).isCorresponding(child); } } return Boolean.TRUE; @@ -97,7 +97,7 @@ public Boolean getisDescriptionValidText() { public Boolean getisFieldValidSeq() { for (VeraPDFXMPNode child : this.xmpNode.getChildren()) { if (XMPConst.NS_PDFA_TYPE.equals(child.getNamespaceURI()) && FIELD.equals(child.getName())) { - return Boolean.valueOf(child.getOptions().isArrayOrdered()); + return child.getOptions().isArrayOrdered(); } } return Boolean.TRUE; @@ -107,7 +107,7 @@ public Boolean getisFieldValidSeq() { public Boolean getisNamespaceURIValidURI() { for (VeraPDFXMPNode child : this.xmpNode.getChildren()) { if (XMPConst.NS_PDFA_TYPE.equals(child.getNamespaceURI()) && NAMESPACE_URI.equals(child.getName())) { - return Boolean.valueOf(new URITypeValidator().isCorresponding(child)); + return new URITypeValidator().isCorresponding(child); } } return Boolean.TRUE; @@ -117,7 +117,7 @@ public Boolean getisNamespaceURIValidURI() { public Boolean getisPrefixValidText() { for (VeraPDFXMPNode child : this.xmpNode.getChildren()) { if (XMPConst.NS_PDFA_TYPE.equals(child.getNamespaceURI()) && PREFIX.equals(child.getName())) { - return Boolean.valueOf(SimpleTypeValidator.fromValue(SimpleTypeValidator.SimpleTypeEnum.TEXT).isCorresponding(child)); + return SimpleTypeValidator.fromValue(SimpleTypeValidator.SimpleTypeEnum.TEXT).isCorresponding(child); } } return Boolean.TRUE; @@ -127,7 +127,7 @@ public Boolean getisPrefixValidText() { public Boolean getisTypeValidText() { for (VeraPDFXMPNode child : this.xmpNode.getChildren()) { if (XMPConst.NS_PDFA_TYPE.equals(child.getNamespaceURI()) && TYPE.equals(child.getName())) { - return Boolean.valueOf(SimpleTypeValidator.fromValue(SimpleTypeValidator.SimpleTypeEnum.TEXT).isCorresponding(child)); + return SimpleTypeValidator.fromValue(SimpleTypeValidator.SimpleTypeEnum.TEXT).isCorresponding(child); } } return Boolean.TRUE; @@ -183,10 +183,12 @@ public String gettypePrefix() { return null; } + @Override protected String getValidNamespaceURI() { return XMPConst.NS_PDFA_TYPE; } + @Override protected Set getValidChildNames() { return validChildNames; } diff --git a/core/src/main/java/org/verapdf/model/impl/axl/AXLExtensionSchemasContainer.java b/core/src/main/java/org/verapdf/model/impl/axl/AXLExtensionSchemasContainer.java index f4d9cc598..40e407752 100644 --- a/core/src/main/java/org/verapdf/model/impl/axl/AXLExtensionSchemasContainer.java +++ b/core/src/main/java/org/verapdf/model/impl/axl/AXLExtensionSchemasContainer.java @@ -44,7 +44,7 @@ public class AXLExtensionSchemasContainer extends AXLXMPObject implements Extens public static final String EXTENSION_SCHEMA_DEFINITIONS = "ExtensionSchemaDefinitions"; - protected VeraPDFXMPNode xmpNode; + protected final VeraPDFXMPNode xmpNode; protected final Map containerForPDFA_1; protected final Map containerForPDFA_2_3; protected final PDFAFlavour flavour; @@ -100,7 +100,7 @@ private List getExtensionSchemaDefinitions() { @Override public Boolean getisValidBag() { PropertyOptions options = this.xmpNode.getOptions(); - return Boolean.valueOf(options.isArray() && !(options.isArrayOrdered() || options.isArrayAlternate())); + return options.isArray() && !(options.isArrayOrdered() || options.isArrayAlternate()); } @Override diff --git a/core/src/main/java/org/verapdf/model/impl/axl/AXLPDFAIdentification.java b/core/src/main/java/org/verapdf/model/impl/axl/AXLPDFAIdentification.java index 3503abe06..15239b2c4 100644 --- a/core/src/main/java/org/verapdf/model/impl/axl/AXLPDFAIdentification.java +++ b/core/src/main/java/org/verapdf/model/impl/axl/AXLPDFAIdentification.java @@ -50,7 +50,7 @@ public AXLPDFAIdentification(VeraPDFMeta metadata) { public Long getpart() { try { Integer part = this.metadata.getPDFAIdentificationPart(); - return part == null ? null : Long.valueOf(part.longValue()); + return part == null ? null : part.longValue(); } catch (XMPException e) { LOGGER.log(Level.FINE, "Can not get PDF/A identification part", e); return null; diff --git a/core/src/main/java/org/verapdf/model/impl/axl/AXLPDFUAIdentification.java b/core/src/main/java/org/verapdf/model/impl/axl/AXLPDFUAIdentification.java index 52d23f371..c41fd60eb 100644 --- a/core/src/main/java/org/verapdf/model/impl/axl/AXLPDFUAIdentification.java +++ b/core/src/main/java/org/verapdf/model/impl/axl/AXLPDFUAIdentification.java @@ -26,7 +26,7 @@ public AXLPDFUAIdentification(VeraPDFMeta metadata) { public Long getpart() { try { Integer part = this.metadata.getPDFUAIdentificationPart(); - return part == null ? null : Long.valueOf(part.longValue()); + return part == null ? null : part.longValue(); } catch (XMPException e) { LOGGER.log(Level.FINE, "Can not get PDF/UA identification part", e); return null; diff --git a/core/src/main/java/org/verapdf/model/impl/axl/AXLXMPPackage.java b/core/src/main/java/org/verapdf/model/impl/axl/AXLXMPPackage.java index 8929b35e8..d23484032 100644 --- a/core/src/main/java/org/verapdf/model/impl/axl/AXLXMPPackage.java +++ b/core/src/main/java/org/verapdf/model/impl/axl/AXLXMPPackage.java @@ -171,7 +171,7 @@ protected VeraPDFMeta getXmpMetadata() { @Override public Boolean getisSerializationValid() { - return Boolean.valueOf(this.isSerializationValid); + return this.isSerializationValid; } //------------------------------------------------------------------------------ veraPDF: getter method for actual encoding diff --git a/core/src/main/java/org/verapdf/model/impl/axl/AXLXMPProperty.java b/core/src/main/java/org/verapdf/model/impl/axl/AXLXMPProperty.java index 93f87a7fb..3551cd79b 100644 --- a/core/src/main/java/org/verapdf/model/impl/axl/AXLXMPProperty.java +++ b/core/src/main/java/org/verapdf/model/impl/axl/AXLXMPProperty.java @@ -38,8 +38,8 @@ public class AXLXMPProperty extends AXLXMPObject implements XMPProperty { private final boolean isClosedChoiceCheck; private final PDFAFlavour flavour; private final SchemasDefinition mainPackageSchemasDefinition; - private SchemasDefinition currentSchemasDefinitionPDFA_1; - private SchemasDefinition currentSchemasDefinitionPDFA_2_3; + private final SchemasDefinition currentSchemasDefinitionPDFA_1; + private final SchemasDefinition currentSchemasDefinitionPDFA_2_3; public AXLXMPProperty(VeraPDFXMPNode xmpNode, boolean isMainMetadata, boolean isClosedChoiceCheck, SchemasDefinition mainPackageSchemasDefinition, SchemasDefinition currentSchemasDefinitionPDFA_1, SchemasDefinition currentSchemasDefinitionPDFA_2_3, PDFAFlavour flavour) { this(xmpNode, XMP_PROPERTY_TYPE, isMainMetadata, isClosedChoiceCheck, mainPackageSchemasDefinition, currentSchemasDefinitionPDFA_1, currentSchemasDefinitionPDFA_2_3, flavour); @@ -64,26 +64,25 @@ public String getID() { @Override public Boolean getisPredefinedInXMP2004() { - return Boolean.valueOf(SchemasDefinitionCreator.getPredefinedSchemaDefinitionForPDFA_1(this.isClosedChoiceCheck).isDefinedProperty(this.xmpNode)); + return SchemasDefinitionCreator.getPredefinedSchemaDefinitionForPDFA_1(this.isClosedChoiceCheck).isDefinedProperty(this.xmpNode); } @Override public Boolean getisPredefinedInXMP2005() { - return Boolean.valueOf(SchemasDefinitionCreator.getPredefinedSchemaDefinitionForPDFA_2_3(this.isClosedChoiceCheck).isDefinedProperty(this.xmpNode)); + return SchemasDefinitionCreator.getPredefinedSchemaDefinitionForPDFA_2_3(this.isClosedChoiceCheck).isDefinedProperty(this.xmpNode); } @Override public Boolean getisDefinedInCurrentPackage() { if (this.flavour != null && this.flavour.getPart() == PDFAFlavour.Specification.ISO_19005_1) { - return Boolean.valueOf(this.currentSchemasDefinitionPDFA_1.isDefinedProperty(this.xmpNode)); + return this.currentSchemasDefinitionPDFA_1.isDefinedProperty(this.xmpNode); } - return Boolean.valueOf(this.currentSchemasDefinitionPDFA_2_3.isDefinedProperty(this.xmpNode)); + return this.currentSchemasDefinitionPDFA_2_3.isDefinedProperty(this.xmpNode); } @Override public Boolean getisDefinedInMainPackage() { - return this.isMainMetadata ? Boolean.valueOf(this.currentSchemasDefinitionPDFA_2_3.isDefinedProperty(this.xmpNode)) : - Boolean.valueOf(this.mainPackageSchemasDefinition.isDefinedProperty(this.xmpNode)); + return (this.isMainMetadata ? this.currentSchemasDefinitionPDFA_2_3 : this.mainPackageSchemasDefinition).isDefinedProperty(this.xmpNode); } @Override diff --git a/core/src/main/java/org/verapdf/model/tools/xmp/PredefinedSchemasDefinition.java b/core/src/main/java/org/verapdf/model/tools/xmp/PredefinedSchemasDefinition.java index 34821c137..ae84a6851 100644 --- a/core/src/main/java/org/verapdf/model/tools/xmp/PredefinedSchemasDefinition.java +++ b/core/src/main/java/org/verapdf/model/tools/xmp/PredefinedSchemasDefinition.java @@ -33,9 +33,9 @@ */ public class PredefinedSchemasDefinition extends SchemasDefinition { - private Map restrictedSimpleField = new HashMap<>(); - private Map restrictedSeqText = new HashMap<>(); - private Map closedSeqChoice = new HashMap<>(); + private final Map restrictedSimpleField = new HashMap<>(); + private final Map restrictedSeqText = new HashMap<>(); + private final Map closedSeqChoice = new HashMap<>(); protected PredefinedSchemasDefinition() { } @@ -71,7 +71,7 @@ public Boolean isCorrespondsDefinedType(VeraPDFXMPNode node) { } private static Boolean isCorrespondsClosedSimpleChoice(VeraPDFXMPNode node, Pattern p) { - return Boolean.valueOf(node.getOptions().isSimple() && p.matcher(node.getValue()).matches()); + return node.getOptions().isSimple() && p.matcher(node.getValue()).matches(); } private static Boolean isCorrespondsRestrictedSeqText(VeraPDFXMPNode node, Pattern p) { diff --git a/core/src/main/java/org/verapdf/model/tools/xmp/SchemasDefinition.java b/core/src/main/java/org/verapdf/model/tools/xmp/SchemasDefinition.java index 2c559868e..312b8024b 100644 --- a/core/src/main/java/org/verapdf/model/tools/xmp/SchemasDefinition.java +++ b/core/src/main/java/org/verapdf/model/tools/xmp/SchemasDefinition.java @@ -32,8 +32,8 @@ */ public class SchemasDefinition { - private Map properties = new HashMap<>(); - private ValidatorsContainer validator; + private final Map properties = new HashMap<>(); + private final ValidatorsContainer validator; protected SchemasDefinition() { this(null); @@ -64,7 +64,7 @@ public Boolean isCorrespondsDefinedType(VeraPDFXMPNode node) { return null; } String type = getType(node); - return type == null ? null : Boolean.valueOf(this.validator.validate(node, type)); + return type == null ? null : this.validator.validate(node, type); } public String getDefinedType(VeraPDFXMPNode node) { diff --git a/core/src/main/java/org/verapdf/model/tools/xmp/ValidatorsContainer.java b/core/src/main/java/org/verapdf/model/tools/xmp/ValidatorsContainer.java index c495f7302..1085f9ad0 100644 --- a/core/src/main/java/org/verapdf/model/tools/xmp/ValidatorsContainer.java +++ b/core/src/main/java/org/verapdf/model/tools/xmp/ValidatorsContainer.java @@ -32,8 +32,8 @@ */ public class ValidatorsContainer { - private Map validators; - private Map arrayValidators; + private final Map validators; + private final Map arrayValidators; /** * Creates new validators container and initialize all array types and simple types diff --git a/core/src/main/java/org/verapdf/model/tools/xmp/ValidatorsContainerCreator.java b/core/src/main/java/org/verapdf/model/tools/xmp/ValidatorsContainerCreator.java index a6ed55ac6..b4b641c0c 100644 --- a/core/src/main/java/org/verapdf/model/tools/xmp/ValidatorsContainerCreator.java +++ b/core/src/main/java/org/verapdf/model/tools/xmp/ValidatorsContainerCreator.java @@ -34,7 +34,7 @@ */ public class ValidatorsContainerCreator { - public static ValidatorsContainer EMPTY_VALIDATORS_CONTAINER = new ValidatorsContainer(); + public static final ValidatorsContainer EMPTY_VALIDATORS_CONTAINER = new ValidatorsContainer(); private static ValidatorsContainer PREDEFINED_CONTAINER_WITHOUT_CLOSED_CHOICE_FOR_PDFA_1 = null; private static ValidatorsContainer PREDEFINED_CONTAINER_WITHOUT_CLOSED_CHOICE_FOR_PDFA_2_3 = null; private static ValidatorsContainer PREDEFINED_CONTAINER_WITH_CLOSED_CHOICE_FOR_PDFA_1 = null; diff --git a/core/src/main/java/org/verapdf/model/tools/xmp/validators/ArrayTypeValidator.java b/core/src/main/java/org/verapdf/model/tools/xmp/validators/ArrayTypeValidator.java index 1dc433e96..a6be4d100 100644 --- a/core/src/main/java/org/verapdf/model/tools/xmp/validators/ArrayTypeValidator.java +++ b/core/src/main/java/org/verapdf/model/tools/xmp/validators/ArrayTypeValidator.java @@ -30,8 +30,8 @@ */ public class ArrayTypeValidator { - private ArrayTypeEnum type; - private ValidatorsContainer parentContainer; + private final ArrayTypeEnum type; + private final ValidatorsContainer parentContainer; private ArrayTypeValidator(ArrayTypeEnum type, ValidatorsContainer parentContainer) { this.type = type; @@ -88,7 +88,7 @@ public enum ArrayTypeEnum { ALT(XMPConstants.ALT), SEQ(XMPConstants.SEQ); - private String type; + private final String type; ArrayTypeEnum(String type) { this.type = type; diff --git a/core/src/main/java/org/verapdf/model/tools/xmp/validators/SimpleTypeValidator.java b/core/src/main/java/org/verapdf/model/tools/xmp/validators/SimpleTypeValidator.java index 732eab048..db25186ce 100644 --- a/core/src/main/java/org/verapdf/model/tools/xmp/validators/SimpleTypeValidator.java +++ b/core/src/main/java/org/verapdf/model/tools/xmp/validators/SimpleTypeValidator.java @@ -30,7 +30,7 @@ */ public class SimpleTypeValidator implements TypeValidator { - private Pattern pattern; + private final Pattern pattern; private SimpleTypeValidator(Pattern pattern) { this.pattern = pattern; @@ -71,8 +71,8 @@ public enum SimpleTypeEnum { RATIONAL(XMPConstants.RATIONAL, "(?s)(^.*$)"), RENDITION_CLASS(XMPConstants.RENDITION_CLASS, "(?s)(^.*$)"); - private String type; - private String regexp; + private final String type; + private final String regexp; SimpleTypeEnum(String type, String regexp) { this.type = type; diff --git a/core/src/main/java/org/verapdf/model/tools/xmp/validators/StructuredTypeValidator.java b/core/src/main/java/org/verapdf/model/tools/xmp/validators/StructuredTypeValidator.java index d909a4700..cd6c1f88c 100644 --- a/core/src/main/java/org/verapdf/model/tools/xmp/validators/StructuredTypeValidator.java +++ b/core/src/main/java/org/verapdf/model/tools/xmp/validators/StructuredTypeValidator.java @@ -31,9 +31,9 @@ */ public class StructuredTypeValidator implements TypeValidator { - private String childNamespaceURI; - private Map childrenTypes; - private ValidatorsContainer parentContainer; + private final String childNamespaceURI; + private final Map childrenTypes; + private final ValidatorsContainer parentContainer; private StructuredTypeValidator(String childNamespaceURI, Map childrenTypes, ValidatorsContainer parentContainer) { this.childNamespaceURI = childNamespaceURI; diff --git a/core/src/main/java/org/verapdf/model/tools/xmp/validators/StructuredTypeWithRestrictedFieldsValidator.java b/core/src/main/java/org/verapdf/model/tools/xmp/validators/StructuredTypeWithRestrictedFieldsValidator.java index 20fd5c10f..5fe8cc09d 100644 --- a/core/src/main/java/org/verapdf/model/tools/xmp/validators/StructuredTypeWithRestrictedFieldsValidator.java +++ b/core/src/main/java/org/verapdf/model/tools/xmp/validators/StructuredTypeWithRestrictedFieldsValidator.java @@ -32,10 +32,10 @@ */ public class StructuredTypeWithRestrictedFieldsValidator implements TypeValidator { - private String childNamespaceURI; - private Map childrenTypes; - private Map childrenChoiceTypes; - private ValidatorsContainer parentContainer; + private final String childNamespaceURI; + private final Map childrenTypes; + private final Map childrenChoiceTypes; + private final ValidatorsContainer parentContainer; public StructuredTypeWithRestrictedFieldsValidator(String childNamespaceURI, Map childrenTypes, Map childrenChoiceTypes, ValidatorsContainer parentContainer) { this.childNamespaceURI = childNamespaceURI; diff --git a/core/src/main/java/org/verapdf/pdfa/Foundries.java b/core/src/main/java/org/verapdf/pdfa/Foundries.java index 38358fa6a..bbb238107 100644 --- a/core/src/main/java/org/verapdf/pdfa/Foundries.java +++ b/core/src/main/java/org/verapdf/pdfa/Foundries.java @@ -44,7 +44,7 @@ public class Foundries { private Foundries() { } - private static Map providers = new ConcurrentHashMap<>(); + private static final Map providers = new ConcurrentHashMap<>(); /** * return the {@link URI} identifying the default diff --git a/core/src/main/java/org/verapdf/pdfa/flavours/PDFAFlavour.java b/core/src/main/java/org/verapdf/pdfa/flavours/PDFAFlavour.java index 33379c6e9..33543ed8c 100644 --- a/core/src/main/java/org/verapdf/pdfa/flavours/PDFAFlavour.java +++ b/core/src/main/java/org/verapdf/pdfa/flavours/PDFAFlavour.java @@ -101,7 +101,7 @@ public enum PDFAFlavour { /** wcag PDF version 2.1 */ WCAG2_1(Specification.WCAG_2_1, Level.NO_LEVEL); - private final static Map FLAVOUR_LOOKUP = new HashMap<>(); + private static final Map FLAVOUR_LOOKUP = new HashMap<>(); static { for (PDFAFlavour flavour : PDFAFlavour.values()) { FLAVOUR_LOOKUP.put(flavour.id, flavour); diff --git a/core/src/main/java/org/verapdf/pdfa/parsers/pkcs7/DEREncodedValue.java b/core/src/main/java/org/verapdf/pdfa/parsers/pkcs7/DEREncodedValue.java index e8db81956..54987a054 100644 --- a/core/src/main/java/org/verapdf/pdfa/parsers/pkcs7/DEREncodedValue.java +++ b/core/src/main/java/org/verapdf/pdfa/parsers/pkcs7/DEREncodedValue.java @@ -5,7 +5,7 @@ import java.math.BigInteger; public class DEREncodedValue { - public byte valueTag; + public final byte valueTag; public final DEREncodedInputStream in; private int length; diff --git a/core/src/main/java/org/verapdf/pdfa/results/MetadataFixerResultImpl.java b/core/src/main/java/org/verapdf/pdfa/results/MetadataFixerResultImpl.java index 71e49c39d..3c87caacf 100644 --- a/core/src/main/java/org/verapdf/pdfa/results/MetadataFixerResultImpl.java +++ b/core/src/main/java/org/verapdf/pdfa/results/MetadataFixerResultImpl.java @@ -20,10 +20,7 @@ */ package org.verapdf.pdfa.results; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; +import java.util.*; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; @@ -43,7 +40,7 @@ public final class MetadataFixerResultImpl implements MetadataFixerResult { private final List appliedFixes; private MetadataFixerResultImpl() { - this(RepairStatus.NO_ACTION, new ArrayList()); + this(RepairStatus.NO_ACTION, new ArrayList<>()); } private MetadataFixerResultImpl(final RepairStatus status, final List fixes) { @@ -87,8 +84,7 @@ public boolean equals(Object o) { if (this.status != strings.status) return false; - return this.appliedFixes != null ? this.appliedFixes.equals(strings.appliedFixes) - : strings.appliedFixes == null; + return Objects.equals(this.appliedFixes, strings.appliedFixes); } diff --git a/core/src/main/java/org/verapdf/pdfa/results/ValidationResultImpl.java b/core/src/main/java/org/verapdf/pdfa/results/ValidationResultImpl.java index f18284ae2..b8ae67f0b 100644 --- a/core/src/main/java/org/verapdf/pdfa/results/ValidationResultImpl.java +++ b/core/src/main/java/org/verapdf/pdfa/results/ValidationResultImpl.java @@ -63,7 +63,7 @@ final class ValidationResultImpl implements ValidationResult { private final ValidationProfile validationProfile; private ValidationResultImpl() { - this(Profiles.defaultProfile(), Collections.emptyList(), + this(Profiles.defaultProfile(), Collections.emptyList(), false, JobEndStatus.NORMAL); } @@ -145,6 +145,7 @@ public JobEndStatus getJobEndStatus() { return this.jobEndStatus; } + @Override public HashMap getFailedChecks() { return this.failedChecks; } @@ -175,16 +176,10 @@ public boolean equals(Object obj) { return false; if (getClass() != obj.getClass()) return false; - if (!(obj instanceof ValidationResult)) - return false; ValidationResult other = (ValidationResult) obj; - if (this.assertions == null) { - if (other.getTestAssertions() != null) - return false; - } else if (other.getTestAssertions() == null) - return false; - else if (!this.assertions.equals(other.getTestAssertions())) + if (!Objects.equals(this.assertions, other.getTestAssertions())) { return false; + } if (this.flavour != other.getPDFAFlavour()) return false; if (this.isCompliant != other.isCompliant()) diff --git a/core/src/main/java/org/verapdf/pdfa/validation/profiles/ErrorArgumentImpl.java b/core/src/main/java/org/verapdf/pdfa/validation/profiles/ErrorArgumentImpl.java index a6797ed14..4c691a005 100644 --- a/core/src/main/java/org/verapdf/pdfa/validation/profiles/ErrorArgumentImpl.java +++ b/core/src/main/java/org/verapdf/pdfa/validation/profiles/ErrorArgumentImpl.java @@ -31,7 +31,7 @@ @XmlRootElement(name = "argument") @XmlAccessorType(XmlAccessType.NONE) public final class ErrorArgumentImpl implements ErrorArgument { - private final static ErrorArgumentImpl DEFAULT = new ErrorArgumentImpl(); + private static final ErrorArgumentImpl DEFAULT = new ErrorArgumentImpl(); @XmlValue private final String argument; @XmlAttribute(name = "name") diff --git a/core/src/main/java/org/verapdf/pdfa/validation/profiles/ErrorDetailsImpl.java b/core/src/main/java/org/verapdf/pdfa/validation/profiles/ErrorDetailsImpl.java index 167d910b1..73e20f1c4 100644 --- a/core/src/main/java/org/verapdf/pdfa/validation/profiles/ErrorDetailsImpl.java +++ b/core/src/main/java/org/verapdf/pdfa/validation/profiles/ErrorDetailsImpl.java @@ -36,7 +36,7 @@ */ @XmlRootElement(name = "error") final class ErrorDetailsImpl implements ErrorDetails { - private final static ErrorDetailsImpl DEFAULT = new ErrorDetailsImpl(); + private static final ErrorDetailsImpl DEFAULT = new ErrorDetailsImpl(); @XmlElement private final String message; @XmlElementWrapper @@ -44,7 +44,7 @@ final class ErrorDetailsImpl implements ErrorDetails { private final List arguments; private ErrorDetailsImpl() { - this("message", Collections. emptyList()); + this("message", Collections.emptyList()); } private ErrorDetailsImpl(final String message, final List arguments) { diff --git a/core/src/main/java/org/verapdf/pdfa/validation/profiles/ProfileDirectoryImpl.java b/core/src/main/java/org/verapdf/pdfa/validation/profiles/ProfileDirectoryImpl.java index e683ff2fc..286e3cbb6 100644 --- a/core/src/main/java/org/verapdf/pdfa/validation/profiles/ProfileDirectoryImpl.java +++ b/core/src/main/java/org/verapdf/pdfa/validation/profiles/ProfileDirectoryImpl.java @@ -43,8 +43,8 @@ * */ final class ProfileDirectoryImpl implements ProfileDirectory { - private final static String PROFILE_RESOURCE_ROOT = "org/verapdf/pdfa/validation/"; - private final static String XML_SUFFIX = ".xml"; + private static final String PROFILE_RESOURCE_ROOT = "org/verapdf/pdfa/validation/"; + private static final String XML_SUFFIX = ".xml"; private static final ProfileDirectoryImpl DEFAULT = makeVeraProfileDir(); private final Directory profileDir; diff --git a/core/src/main/java/org/verapdf/pdfa/validation/profiles/Profiles.java b/core/src/main/java/org/verapdf/pdfa/validation/profiles/Profiles.java index 66b5b1a2f..a1edadc12 100644 --- a/core/src/main/java/org/verapdf/pdfa/validation/profiles/Profiles.java +++ b/core/src/main/java/org/verapdf/pdfa/validation/profiles/Profiles.java @@ -559,7 +559,7 @@ public static String getValidationProfileSchema() throws JAXBException, IOExcept public static class RuleIdComparator implements Comparator { @Override public int compare(RuleId firstId, RuleId secondId) { - if (!firstId.getSpecification().equals(secondId.getSpecification())) { + if (firstId.getSpecification() != secondId.getSpecification()) { return firstId.getSpecification().compareTo(secondId.getSpecification()); } if (firstId.getClause().equals(secondId.getClause())) { diff --git a/core/src/main/java/org/verapdf/pdfa/validation/profiles/ReferenceImpl.java b/core/src/main/java/org/verapdf/pdfa/validation/profiles/ReferenceImpl.java index c4f5578b8..dc369b917 100644 --- a/core/src/main/java/org/verapdf/pdfa/validation/profiles/ReferenceImpl.java +++ b/core/src/main/java/org/verapdf/pdfa/validation/profiles/ReferenceImpl.java @@ -38,7 +38,7 @@ */ @XmlRootElement(name = "reference") final class ReferenceImpl implements Reference { - private final static ReferenceImpl DEFAULT = new ReferenceImpl(); + private static final ReferenceImpl DEFAULT = new ReferenceImpl(); @XmlAttribute private final String specification; @XmlAttribute diff --git a/core/src/main/java/org/verapdf/pdfa/validation/profiles/RuleImpl.java b/core/src/main/java/org/verapdf/pdfa/validation/profiles/RuleImpl.java index 0ef3150c5..63360649a 100644 --- a/core/src/main/java/org/verapdf/pdfa/validation/profiles/RuleImpl.java +++ b/core/src/main/java/org/verapdf/pdfa/validation/profiles/RuleImpl.java @@ -41,7 +41,7 @@ */ @XmlRootElement(name = "rule") final class RuleImpl implements Rule { - private final static RuleImpl DEFAULT = new RuleImpl(); + private static final RuleImpl DEFAULT = new RuleImpl(); @XmlElement private final RuleId id; @XmlAttribute @@ -62,7 +62,7 @@ final class RuleImpl implements Rule { private RuleImpl() { this(RuleIdImpl.defaultInstance(), "object", null, null, "description", "test", - ErrorDetailsImpl.defaultInstance(), Collections. emptyList()); + ErrorDetailsImpl.defaultInstance(), Collections.emptyList()); } private RuleImpl(final RuleId id, final String object, final Boolean deferred, final String tags, diff --git a/core/src/main/java/org/verapdf/pdfa/validation/profiles/ValidationProfileImpl.java b/core/src/main/java/org/verapdf/pdfa/validation/profiles/ValidationProfileImpl.java index d199a4063..07a130837 100644 --- a/core/src/main/java/org/verapdf/pdfa/validation/profiles/ValidationProfileImpl.java +++ b/core/src/main/java/org/verapdf/pdfa/validation/profiles/ValidationProfileImpl.java @@ -40,8 +40,8 @@ final class ValidationProfileImpl implements ValidationProfile { private Map> objectRuleMap; private Map> objectVariableMap; - private Map ruleLookup = new HashMap<>(); - private final static ValidationProfileImpl DEFAULT = new ValidationProfileImpl(); + private final Map ruleLookup = new HashMap<>(); + private static final ValidationProfileImpl DEFAULT = new ValidationProfileImpl(); @XmlAttribute private final PDFAFlavour flavour; @@ -58,7 +58,7 @@ final class ValidationProfileImpl implements ValidationProfile { private ValidationProfileImpl() { this(PDFAFlavour.NO_FLAVOUR, ProfileDetailsImpl.defaultInstance(), - "hash", Collections. emptySet(), Collections. emptySet()); + "hash", Collections.emptySet(), Collections.emptySet()); } private ValidationProfileImpl(final PDFAFlavour flavour, @@ -132,7 +132,7 @@ public Set getRulesByObject(final String objectName) { this.objectRuleMap = createObjectRuleMap(this.rules); } Set objRules = this.objectRuleMap.get(objectName); - return objRules == null ? Collections. emptySet() : Collections.unmodifiableSet(objRules); + return objRules == null ? Collections.emptySet() : Collections.unmodifiableSet(objRules); } /** @@ -144,7 +144,7 @@ public Set getVariablesByObject(String objectName) { this.objectVariableMap = createObjectVariableMap(this.variables); } Set objRules = this.objectVariableMap.get(objectName); - return objRules == null ? Collections. emptySet() : Collections.unmodifiableSet(objRules); + return objRules == null ? Collections.emptySet() : Collections.unmodifiableSet(objRules); } /** @@ -272,7 +272,7 @@ private Map> createObjectRuleMap( for (Rule rule : rulesToSet) { this.ruleLookup.put(rule.getRuleId(), rule); if (!rulesByObject.containsKey(rule.getObject())) { - rulesByObject.put(rule.getObject(), new HashSet()); + rulesByObject.put(rule.getObject(), new HashSet<>()); } rulesByObject.get(rule.getObject()).add(rule); } @@ -284,8 +284,7 @@ private static Map> createObjectVariableMap( Map> variablesByObject = new HashMap<>(); for (Variable rule : variables) { if (!variablesByObject.containsKey(rule.getObject())) { - variablesByObject - .put(rule.getObject(), new HashSet()); + variablesByObject.put(rule.getObject(), new HashSet<>()); } variablesByObject.get(rule.getObject()).add(rule); } diff --git a/core/src/main/java/org/verapdf/pdfa/validation/profiles/VariableImpl.java b/core/src/main/java/org/verapdf/pdfa/validation/profiles/VariableImpl.java index 81e2026c8..04a91a9e4 100644 --- a/core/src/main/java/org/verapdf/pdfa/validation/profiles/VariableImpl.java +++ b/core/src/main/java/org/verapdf/pdfa/validation/profiles/VariableImpl.java @@ -39,7 +39,7 @@ */ @XmlRootElement(name = "variable") final class VariableImpl implements Variable { - private final static VariableImpl DEFAULT = new VariableImpl(); + private static final VariableImpl DEFAULT = new VariableImpl(); @XmlAttribute private final String name; @XmlAttribute diff --git a/core/src/main/java/org/verapdf/pdfa/validation/validators/BaseValidator.java b/core/src/main/java/org/verapdf/pdfa/validation/validators/BaseValidator.java index 6aa439fea..13689a323 100644 --- a/core/src/main/java/org/verapdf/pdfa/validation/validators/BaseValidator.java +++ b/core/src/main/java/org/verapdf/pdfa/validation/validators/BaseValidator.java @@ -67,10 +67,10 @@ public class BaseValidator implements PDFAValidator { protected final int maxNumberOfDisplayedFailedChecks; protected boolean isCompliant = true; private boolean showErrorMessages = false; - protected ValidationProgress validationProgress; + protected final ValidationProgress validationProgress; protected volatile JobEndStatus jobEndStatus = JobEndStatus.NORMAL; - private Set idSet = new HashSet<>(); + private final Set idSet = new HashSet<>(); protected String rootType; @@ -297,7 +297,7 @@ private boolean checkAllRules(Object checkObject, String checkContext) { private boolean firstProcessObjectWithRule(Object checkObject, String checkContext, Rule rule) { Boolean deferred = rule.getDeferred(); - if (deferred != null && deferred.booleanValue()) { + if (deferred != null && deferred) { List list = this.deferredRules.computeIfAbsent(rule, k -> new ArrayList<>()); list.add(new ObjectWithContext(checkObject, checkContext)); return true; diff --git a/core/src/main/java/org/verapdf/pdfa/validation/validators/JavaScriptEvaluator.java b/core/src/main/java/org/verapdf/pdfa/validation/validators/JavaScriptEvaluator.java index a01667018..2b8eec497 100644 --- a/core/src/main/java/org/verapdf/pdfa/validation/validators/JavaScriptEvaluator.java +++ b/core/src/main/java/org/verapdf/pdfa/validation/validators/JavaScriptEvaluator.java @@ -20,9 +20,9 @@ public class JavaScriptEvaluator { private static Context context; - private static Map ruleScripts = new HashMap<>(); - private static Map variableScripts = new HashMap<>(); - private static Map argumentScripts = new HashMap<>(); + private static final Map ruleScripts = new HashMap<>(); + private static final Map variableScripts = new HashMap<>(); + private static final Map argumentScripts = new HashMap<>(); public static synchronized ScriptableObject initialise() { context = Context.enter(); @@ -119,7 +119,7 @@ public static synchronized boolean getTestEvalResult(Object obj, Rule rule, Scri scr = ruleScripts.get(test); } - boolean testEvalResult = ((Boolean) scr.exec(context, scope)).booleanValue(); + boolean testEvalResult = (Boolean) scr.exec(context, scope); return testEvalResult; } diff --git a/core/src/main/java/org/verapdf/policy/PolicyChecker.java b/core/src/main/java/org/verapdf/policy/PolicyChecker.java index 6f6e3d255..113da8d3a 100644 --- a/core/src/main/java/org/verapdf/policy/PolicyChecker.java +++ b/core/src/main/java/org/verapdf/policy/PolicyChecker.java @@ -85,7 +85,6 @@ public static void insertPolicyReport(final File policyReport, final File mrrRep Transformer transformer = cachedMergeXsl.newTransformer(); transformer.setParameter("policyResultPath", policyReport.getAbsolutePath()); //$NON-NLS-1$ transformer.transform(new StreamSource(mrrReport), new StreamResult(mergedReport)); - return; } catch (TransformerException excep) { throw new VeraPDFException("Problem merging XML files.", excep); //$NON-NLS-1$ } diff --git a/core/src/main/java/org/verapdf/policy/SchematronGenerator.java b/core/src/main/java/org/verapdf/policy/SchematronGenerator.java index 3b955446e..6d668f2fa 100644 --- a/core/src/main/java/org/verapdf/policy/SchematronGenerator.java +++ b/core/src/main/java/org/verapdf/policy/SchematronGenerator.java @@ -116,10 +116,10 @@ private static String getRuleContext(FeatureObjectType featureType) { } public static class Assertion { - private FeatureObjectType featureType; - private Feature feature; - private SchematronOperation operation; - private String argument; + private final FeatureObjectType featureType; + private final Feature feature; + private final SchematronOperation operation; + private final String argument; public Assertion(FeatureObjectType featureType, Feature feature, SchematronOperation operation, String argument) { if (featureType == null || feature == null || operation == null) { diff --git a/core/src/main/java/org/verapdf/policy/SchematronOperation.java b/core/src/main/java/org/verapdf/policy/SchematronOperation.java index 04919e040..d2c94aa7e 100644 --- a/core/src/main/java/org/verapdf/policy/SchematronOperation.java +++ b/core/src/main/java/org/verapdf/policy/SchematronOperation.java @@ -33,8 +33,8 @@ public enum SchematronOperation { // ENDS_WITH(true, "ends with"), CONTAINS(true, "contains substring"); - private boolean hasArguments; - private String description; + private final boolean hasArguments; + private final String description; SchematronOperation(boolean hasArguments, String description) { this.hasArguments = hasArguments; @@ -116,8 +116,8 @@ public AssertionInformation getAssertionInfo(Feature feature, String argument) { } public static class AssertionInformation { - private String testAssertion; - private String assertionDescription; + private final String testAssertion; + private final String assertionDescription; private AssertionInformation(String testAssertion, String assertionDescription) { this.testAssertion = testAssertion; diff --git a/core/src/main/java/org/verapdf/processor/AbstractBatchHandler.java b/core/src/main/java/org/verapdf/processor/AbstractBatchHandler.java index e67d555ee..5730f28ae 100644 --- a/core/src/main/java/org/verapdf/processor/AbstractBatchHandler.java +++ b/core/src/main/java/org/verapdf/processor/AbstractBatchHandler.java @@ -43,18 +43,18 @@ public abstract class AbstractBatchHandler implements BatchProcessingHandler { public static final String VALIDATION_RESULT = "validationResult"; //$NON-NLS-1$ public static final String FEATURES_REPORT = "featuresReport"; //$NON-NLS-1$ - public final static String FIXER_REPORT = "fixerReport"; //$NON-NLS-1$ + public static final String FIXER_REPORT = "fixerReport"; //$NON-NLS-1$ public static final String FIXER_RESULT = "fixerResult"; //$NON-NLS-1$ - public final static String REPORT = "report"; //$NON-NLS-1$ - public final static String JOB = "job"; //$NON-NLS-1$ - public final static String JOBS = JOB + "s"; //$NON-NLS-1$ - public final static String PROCESSING_TIME = "processingTime"; //$NON-NLS-1$ - public final static String BUILD_INFORMATION = "buildInformation"; //$NON-NLS-1$ - public final static String ITEM_DETAILS = "itemDetails"; //$NON-NLS-1$ - public final static String RELEASE_DETAILS = "releaseDetails"; //$NON-NLS-1$ - public final static String TASK_EXCEPTION = "taskException"; //$NON-NLS-1$ - public final static String BATCH_SUMMARY = "batchSummary"; //$NON-NLS-1$ - public final static String LOGS = "logs"; //$NON-NLS-1$ + public static final String REPORT = "report"; //$NON-NLS-1$ + public static final String JOB = "job"; //$NON-NLS-1$ + public static final String JOBS = JOB + "s"; //$NON-NLS-1$ + public static final String PROCESSING_TIME = "processingTime"; //$NON-NLS-1$ + public static final String BUILD_INFORMATION = "buildInformation"; //$NON-NLS-1$ + public static final String ITEM_DETAILS = "itemDetails"; //$NON-NLS-1$ + public static final String RELEASE_DETAILS = "releaseDetails"; //$NON-NLS-1$ + public static final String TASK_EXCEPTION = "taskException"; //$NON-NLS-1$ + public static final String BATCH_SUMMARY = "batchSummary"; //$NON-NLS-1$ + public static final String LOGS = "logs"; //$NON-NLS-1$ /** * @@ -142,11 +142,11 @@ abstract void fixerSuccess(final TaskResult taskResult, final MetadataFixerResul public static Collection getDurations(ProcessorResult result) { EnumMap results = result.getResults(); - if(results != null) { + if (results != null) { Collection res = new ArrayList<>(); - for (TaskType type : results.keySet()) { - if (results.get(type).getDuration() != null) { - res.add(results.get(type).getDuration()); + for (TaskResult taskResult : results.values()) { + if (taskResult.getDuration() != null) { + res.add(taskResult.getDuration()); } } return res; diff --git a/core/src/main/java/org/verapdf/processor/AbstractBatchProcessor.java b/core/src/main/java/org/verapdf/processor/AbstractBatchProcessor.java index 914a649f6..6283a8b86 100644 --- a/core/src/main/java/org/verapdf/processor/AbstractBatchProcessor.java +++ b/core/src/main/java/org/verapdf/processor/AbstractBatchProcessor.java @@ -105,6 +105,7 @@ public BatchSummary process(final List toProcess, final BatchPro return finishBatch(); } + @Override public BatchSummary process(ItemDetails itemDetails, InputStream stream, BatchProcessingHandler resultHandler) throws VeraPDFException { this.initialise(resultHandler); diff --git a/core/src/main/java/org/verapdf/processor/AbstractXmlHandler.java b/core/src/main/java/org/verapdf/processor/AbstractXmlHandler.java index afc43b472..933afd3da 100644 --- a/core/src/main/java/org/verapdf/processor/AbstractXmlHandler.java +++ b/core/src/main/java/org/verapdf/processor/AbstractXmlHandler.java @@ -38,14 +38,14 @@ public abstract class AbstractXmlHandler extends AbstractBatchHandler { private static final Logger logger = Logger.getLogger(AbstractXmlHandler.class.getCanonicalName()); - protected final static String strmExcpMessTmpl = "XmlStreamException caught when %s output writer."; //$NON-NLS-1$ - protected final static String unmarshalErrMessage = "Unmarshalling exception when streaming %s."; //$NON-NLS-1$ - protected final static String writingMessage = "writing"; //$NON-NLS-1$ - private final static String encoding = "utf-8"; //$NON-NLS-1$ - private final static String xmlVersion = "1.0"; //$NON-NLS-1$ - private final static String lineSepProp = "line.separator"; //$NON-NLS-1$ - private final static String newline = System.getProperty(lineSepProp); - private static XMLOutputFactory outputFactory = XMLOutputFactory.newFactory(); + protected static final String strmExcpMessTmpl = "XmlStreamException caught when %s output writer."; //$NON-NLS-1$ + protected static final String unmarshalErrMessage = "Unmarshalling exception when streaming %s."; //$NON-NLS-1$ + protected static final String writingMessage = "writing"; //$NON-NLS-1$ + private static final String encoding = "utf-8"; //$NON-NLS-1$ + private static final String xmlVersion = "1.0"; //$NON-NLS-1$ + private static final String lineSepProp = "line.separator"; //$NON-NLS-1$ + private static final String newline = System.getProperty(lineSepProp); + private static final XMLOutputFactory outputFactory = XMLOutputFactory.newFactory(); protected XMLStreamWriter writer; diff --git a/core/src/main/java/org/verapdf/processor/FeaturesNodeSerializer.java b/core/src/main/java/org/verapdf/processor/FeaturesNodeSerializer.java index acc56ffca..e9380516d 100644 --- a/core/src/main/java/org/verapdf/processor/FeaturesNodeSerializer.java +++ b/core/src/main/java/org/verapdf/processor/FeaturesNodeSerializer.java @@ -16,6 +16,7 @@ public FeaturesNodeSerializer(Class t) { super(t); } + @Override public void serialize(FeaturesNode featuresNode, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException { diff --git a/core/src/main/java/org/verapdf/processor/ProcessorConfigImpl.java b/core/src/main/java/org/verapdf/processor/ProcessorConfigImpl.java index 13601ceee..fdbca4ec5 100644 --- a/core/src/main/java/org/verapdf/processor/ProcessorConfigImpl.java +++ b/core/src/main/java/org/verapdf/processor/ProcessorConfigImpl.java @@ -34,6 +34,7 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import java.util.EnumSet; +import java.util.Objects; /** * @author Maksim Bezrukov @@ -153,17 +154,17 @@ public boolean equals(Object o) { ProcessorConfigImpl that = (ProcessorConfigImpl) o; - if (tasks != null ? !tasks.equals(that.tasks) : that.tasks != null) return false; - if (validatorConfig != null ? !validatorConfig.equals(that.validatorConfig) : that.validatorConfig != null) + if (!Objects.equals(tasks, that.tasks)) return false; + if (!Objects.equals(validatorConfig, that.validatorConfig)) return false; - if (featureConfig != null ? !featureConfig.equals(that.featureConfig) : that.featureConfig != null) + if (!Objects.equals(featureConfig, that.featureConfig)) return false; - if (pluginsCollectionConfig != null ? !pluginsCollectionConfig.equals(that.pluginsCollectionConfig) : that.pluginsCollectionConfig != null) + if (!Objects.equals(pluginsCollectionConfig, that.pluginsCollectionConfig)) return false; - if (fixerConfig != null ? !fixerConfig.equals(that.fixerConfig) : that.fixerConfig != null) return false; - if (customProfile != null ? !customProfile.equals(that.customProfile) : that.customProfile != null) + if (!Objects.equals(fixerConfig, that.fixerConfig)) return false; + if (!Objects.equals(customProfile, that.customProfile)) return false; - return mdFolder != null ? mdFolder.equals(that.mdFolder) : that.mdFolder == null; + return Objects.equals(mdFolder, that.mdFolder); } diff --git a/core/src/main/java/org/verapdf/processor/ProcessorFactory.java b/core/src/main/java/org/verapdf/processor/ProcessorFactory.java index cd090e5f0..8104f447f 100644 --- a/core/src/main/java/org/verapdf/processor/ProcessorFactory.java +++ b/core/src/main/java/org/verapdf/processor/ProcessorFactory.java @@ -169,10 +169,10 @@ public static final class BatchSummariser { private int encrypted = 0; private int outOfMemory = 0; private int veraExceptions = 0; - private Components.Timer timer = Components.Timer.start(); - private Summarisers.ValidationSummaryBuilder validationBuilder = new Summarisers.ValidationSummaryBuilder(); - private Summarisers.FeatureSummaryBuilder featureBuilder = new Summarisers.FeatureSummaryBuilder(); - private Summarisers.RepairSummaryBuilder repairBuilder = new Summarisers.RepairSummaryBuilder(); + private final Components.Timer timer = Components.Timer.start(); + private final Summarisers.ValidationSummaryBuilder validationBuilder = new Summarisers.ValidationSummaryBuilder(); + private final Summarisers.FeatureSummaryBuilder featureBuilder = new Summarisers.FeatureSummaryBuilder(); + private final Summarisers.RepairSummaryBuilder repairBuilder = new Summarisers.RepairSummaryBuilder(); public BatchSummariser(ProcessorConfig config) { if (config == null) diff --git a/core/src/main/java/org/verapdf/processor/ProcessorImpl.java b/core/src/main/java/org/verapdf/processor/ProcessorImpl.java index 6a38d9ae9..37e957458 100644 --- a/core/src/main/java/org/verapdf/processor/ProcessorImpl.java +++ b/core/src/main/java/org/verapdf/processor/ProcessorImpl.java @@ -64,7 +64,7 @@ final class ProcessorImpl implements ItemProcessor { private static final ComponentDetails defaultDetails = Components .libraryDetails(URI.create("http://pdfa.verapdf.org/processors#default"), "VeraPDF Processor"); //$NON-NLS-1$//$NON-NLS-2$ private static final Logger logger = Logger.getLogger(ProcessorImpl.class.getCanonicalName()); - private static VeraPDFFoundry foundry = Foundries.defaultInstance(); + private static final VeraPDFFoundry foundry = Foundries.defaultInstance(); private final ProcessorConfig processorConfig; private final ComponentDetails details; @@ -228,7 +228,7 @@ private static void checkArguments(InputStream pdfFileStream, ItemDetails fileDe } // FIXME FAST if (config.hasTask(TaskType.VALIDATE) && config.getValidatorConfig().getFlavour() == PDFAFlavour.NO_FLAVOUR - && config.getValidatorConfig().toString().equals("")) { //$NON-NLS-1$ + && "".equals(config.getValidatorConfig().toString())) { //$NON-NLS-1$ throw new IllegalArgumentException("Validation cannot be started with no chosen validation profile"); //$NON-NLS-1$ } if (fileDetails == null) { @@ -352,7 +352,7 @@ public Collection getDependencies() { return ReleaseDetails.getDetails(); } - static private boolean isMdFolder(final String mdFolder) { + private static boolean isMdFolder(final String mdFolder) { if (mdFolder == null) return false; if (mdFolder.isEmpty()) return false; return ! mdFolder.equals(ProcessorConfigImpl.defaultInstance().getMetadataFolder()); diff --git a/core/src/main/java/org/verapdf/processor/ProcessorResultImpl.java b/core/src/main/java/org/verapdf/processor/ProcessorResultImpl.java index 33556cbfd..00c0f54e9 100644 --- a/core/src/main/java/org/verapdf/processor/ProcessorResultImpl.java +++ b/core/src/main/java/org/verapdf/processor/ProcessorResultImpl.java @@ -47,7 +47,7 @@ */ @XmlRootElement(name = "processorResult") class ProcessorResultImpl implements ProcessorResult { - private final static ProcessorResult defaultInstance = new ProcessorResultImpl(); + private static final ProcessorResult defaultInstance = new ProcessorResultImpl(); @XmlAttribute private final boolean isPdf; @XmlAttribute diff --git a/core/src/main/java/org/verapdf/processor/SingleLineResultHandler.java b/core/src/main/java/org/verapdf/processor/SingleLineResultHandler.java index 9d04c1115..e4f0590e7 100644 --- a/core/src/main/java/org/verapdf/processor/SingleLineResultHandler.java +++ b/core/src/main/java/org/verapdf/processor/SingleLineResultHandler.java @@ -41,7 +41,7 @@ class SingleLineResultHandler extends AbstractBatchHandler { private static final String parseExcepMessTmpl = "%s does not appear to be a valid PDF file and could not be parsed.\n"; private static final String pdfEncryptMessTmpl = "%s appears to be an encrypted PDF file and could not be processed.\n"; private static final String ruleMessTmpl = " %s%s-%d\n"; //$NON-NLS-1$ - private PrintWriter outputStreamWriter; + private final PrintWriter outputStreamWriter; private final boolean isVerbose; private final boolean logSuccess; private ItemDetails item; @@ -168,7 +168,7 @@ private void processRules(final ValidationResult validationResult) throws IOExce private void outputRules(final Set rules, final String messStart) throws IOException { for (RuleId id : rules) { - this.outputStreamWriter.write(String.format(ruleMessTmpl, messStart, id.getClause(), Integer.valueOf(id.getTestNumber()))); + this.outputStreamWriter.write(String.format(ruleMessTmpl, messStart, id.getClause(), id.getTestNumber())); } } diff --git a/core/src/main/java/org/verapdf/processor/TaskResultImpl.java b/core/src/main/java/org/verapdf/processor/TaskResultImpl.java index 6f90928f0..b10ef1023 100644 --- a/core/src/main/java/org/verapdf/processor/TaskResultImpl.java +++ b/core/src/main/java/org/verapdf/processor/TaskResultImpl.java @@ -61,13 +61,13 @@ public String getExceptionMessage() { return null; Throwable e = this.exception; - String res = EXCEPTION + e.getMessage(); + StringBuilder res = new StringBuilder(EXCEPTION + e.getMessage()); e = e.getCause(); while (e != null) { - res += CAUSED_BY + e.getMessage(); + res.append(CAUSED_BY).append(e.getMessage()); e = e.getCause(); } - return res; + return res.toString(); } private TaskResultImpl() { diff --git a/core/src/main/java/org/verapdf/processor/VeraPDFExceptionSerializer.java b/core/src/main/java/org/verapdf/processor/VeraPDFExceptionSerializer.java index e6693c418..9192be86d 100644 --- a/core/src/main/java/org/verapdf/processor/VeraPDFExceptionSerializer.java +++ b/core/src/main/java/org/verapdf/processor/VeraPDFExceptionSerializer.java @@ -13,6 +13,7 @@ public VeraPDFExceptionSerializer(Class t) { super(t); } + @Override public void serialize(VeraPDFException exception, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException { jsonGenerator.writeString(exception.getMessage()); diff --git a/core/src/main/java/org/verapdf/processor/plugins/PluginConfig.java b/core/src/main/java/org/verapdf/processor/plugins/PluginConfig.java index 04fc3620b..417f5e66e 100644 --- a/core/src/main/java/org/verapdf/processor/plugins/PluginConfig.java +++ b/core/src/main/java/org/verapdf/processor/plugins/PluginConfig.java @@ -58,7 +58,7 @@ private PluginConfig(boolean enabled, String name, String version, String descri } private PluginConfig() { - this(false, "", "", "","", Collections.emptyList()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$//$NON-NLS-4$ + this(false, "", "", "","", Collections.emptyList()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$//$NON-NLS-4$ } public static PluginConfig fromValues(boolean enabled, String name, String version, String description, String pluginFolder, List attributes) { @@ -86,6 +86,6 @@ public String getPluginJar() { } public List getAttributes() { - return this.attributes == null ? Collections.emptyList() : Collections.unmodifiableList(this.attributes); + return this.attributes == null ? Collections.emptyList() : Collections.unmodifiableList(this.attributes); } } diff --git a/core/src/main/java/org/verapdf/processor/plugins/PluginsCollectionConfig.java b/core/src/main/java/org/verapdf/processor/plugins/PluginsCollectionConfig.java index eba5b9b7a..54fc9e5b0 100644 --- a/core/src/main/java/org/verapdf/processor/plugins/PluginsCollectionConfig.java +++ b/core/src/main/java/org/verapdf/processor/plugins/PluginsCollectionConfig.java @@ -42,11 +42,11 @@ public final class PluginsCollectionConfig { private final List plugin; public PluginsCollectionConfig() { - this(Collections.emptyList()); + this(Collections.emptyList()); } private PluginsCollectionConfig(List pluginsConfig) { - this.plugin = pluginsConfig == null ? Collections.emptyList() : new ArrayList<>(pluginsConfig); + this.plugin = pluginsConfig == null ? Collections.emptyList() : new ArrayList<>(pluginsConfig); } /** diff --git a/core/src/main/java/org/verapdf/processor/reports/CheckImpl.java b/core/src/main/java/org/verapdf/processor/reports/CheckImpl.java index c98cfa09d..13f5b15c2 100644 --- a/core/src/main/java/org/verapdf/processor/reports/CheckImpl.java +++ b/core/src/main/java/org/verapdf/processor/reports/CheckImpl.java @@ -103,6 +103,7 @@ public String getErrorMessage() { /** * @return the error arguments */ + @Override public List getErrorArguments() { return this.errorArguments; } diff --git a/core/src/main/java/org/verapdf/processor/reports/FixerReportImpl.java b/core/src/main/java/org/verapdf/processor/reports/FixerReportImpl.java index b063cafa4..13f5fa1d9 100644 --- a/core/src/main/java/org/verapdf/processor/reports/FixerReportImpl.java +++ b/core/src/main/java/org/verapdf/processor/reports/FixerReportImpl.java @@ -63,7 +63,7 @@ private FixerReportImpl(final String status, final int fixCount, final ListemptyList(), Collections.emptyList()); + this("", 0, Collections.emptyList(), Collections.emptyList()); } /** diff --git a/core/src/main/java/org/verapdf/processor/reports/ResultStructure.java b/core/src/main/java/org/verapdf/processor/reports/ResultStructure.java index cf0c1a7c5..da5b87d6d 100644 --- a/core/src/main/java/org/verapdf/processor/reports/ResultStructure.java +++ b/core/src/main/java/org/verapdf/processor/reports/ResultStructure.java @@ -4,7 +4,7 @@ public class ResultStructure { - private File reportFile; + private final File reportFile; public ResultStructure(File reportFile) { this.reportFile = reportFile; diff --git a/core/src/main/java/org/verapdf/processor/reports/RuleSummaryImpl.java b/core/src/main/java/org/verapdf/processor/reports/RuleSummaryImpl.java index 9c7e15fe4..690aa0f68 100644 --- a/core/src/main/java/org/verapdf/processor/reports/RuleSummaryImpl.java +++ b/core/src/main/java/org/verapdf/processor/reports/RuleSummaryImpl.java @@ -83,7 +83,7 @@ private RuleSummaryImpl(final RuleId ruleId, final Status status, final Integer private RuleSummaryImpl(final RuleId ruleId, final Status status, final String description, final String object, final String test, String tags) { - this(ruleId, status, 0, 0, tags, description, object, test, Collections.emptyList()); + this(ruleId, status, 0, 0, tags, description, object, test, Collections.emptyList()); } private RuleSummaryImpl() { diff --git a/core/src/main/java/org/verapdf/processor/reports/Summarisers.java b/core/src/main/java/org/verapdf/processor/reports/Summarisers.java index 648955185..bdafef133 100644 --- a/core/src/main/java/org/verapdf/processor/reports/Summarisers.java +++ b/core/src/main/java/org/verapdf/processor/reports/Summarisers.java @@ -88,7 +88,7 @@ public MetadataRepairBatchSummary build() { } } - private static abstract class AbstractSummaryBuilder { + private abstract static class AbstractSummaryBuilder { protected int total = 0; protected int failed = 0; private final TaskType taskType; diff --git a/core/src/main/java/org/verapdf/processor/reports/ValidationDetailsImpl.java b/core/src/main/java/org/verapdf/processor/reports/ValidationDetailsImpl.java index 56cc902ed..b5633b4f1 100644 --- a/core/src/main/java/org/verapdf/processor/reports/ValidationDetailsImpl.java +++ b/core/src/main/java/org/verapdf/processor/reports/ValidationDetailsImpl.java @@ -41,7 +41,7 @@ * @version 0.1 Created 10 Nov 2016:08:34:32 */ final class ValidationDetailsImpl implements ValidationDetails { - private final static ValidationDetailsImpl defaultInstance = new ValidationDetailsImpl(); + private static final ValidationDetailsImpl defaultInstance = new ValidationDetailsImpl(); @XmlAttribute private final int passedRules; @XmlAttribute @@ -57,7 +57,7 @@ final class ValidationDetailsImpl implements ValidationDetails { private final Set ruleSummaries; private ValidationDetailsImpl() { - this(0, 0, 0, 0, Collections.emptySet(), null); + this(0, 0, 0, 0, Collections.emptySet(), null); } private ValidationDetailsImpl(final int passedRules, final int failedRules, final int passedChecks, diff --git a/core/src/main/java/org/verapdf/processor/reports/multithread/MultiThreadProcessingHandlerImpl.java b/core/src/main/java/org/verapdf/processor/reports/multithread/MultiThreadProcessingHandlerImpl.java index 8474ee54f..63de4db9d 100644 --- a/core/src/main/java/org/verapdf/processor/reports/multithread/MultiThreadProcessingHandlerImpl.java +++ b/core/src/main/java/org/verapdf/processor/reports/multithread/MultiThreadProcessingHandlerImpl.java @@ -4,7 +4,7 @@ import org.verapdf.processor.reports.multithread.writer.ReportWriter; public class MultiThreadProcessingHandlerImpl implements MultiThreadProcessingHandler { - private ReportWriter reportWriter; + private final ReportWriter reportWriter; public MultiThreadProcessingHandlerImpl(ReportWriter reportWriter) { this.reportWriter = reportWriter; diff --git a/core/src/main/java/org/verapdf/processor/reports/multithread/writer/AbstractXmlReportWriter.java b/core/src/main/java/org/verapdf/processor/reports/multithread/writer/AbstractXmlReportWriter.java index f41ba5d88..4ca9699ba 100644 --- a/core/src/main/java/org/verapdf/processor/reports/multithread/writer/AbstractXmlReportWriter.java +++ b/core/src/main/java/org/verapdf/processor/reports/multithread/writer/AbstractXmlReportWriter.java @@ -43,6 +43,7 @@ public void startDocument() { } } + @Override public void endDocument() { try { this.reportHandler.printSummary(); diff --git a/core/src/main/java/org/verapdf/processor/reports/multithread/writer/JsonReportWriter.java b/core/src/main/java/org/verapdf/processor/reports/multithread/writer/JsonReportWriter.java index cb820faf8..fce959155 100644 --- a/core/src/main/java/org/verapdf/processor/reports/multithread/writer/JsonReportWriter.java +++ b/core/src/main/java/org/verapdf/processor/reports/multithread/writer/JsonReportWriter.java @@ -15,6 +15,7 @@ protected JsonReportWriter(PrintWriter outputStreamWriter, PrintWriter errorStre super(outputStreamWriter, errorStreamWriter); } + @Override public void write(ResultStructure result) { if (isFirstReport) { isFirstReport = false; diff --git a/core/src/main/java/org/verapdf/processor/reports/multithread/writer/MrrReportWriter.java b/core/src/main/java/org/verapdf/processor/reports/multithread/writer/MrrReportWriter.java index eb78901a1..0bdbb1295 100644 --- a/core/src/main/java/org/verapdf/processor/reports/multithread/writer/MrrReportWriter.java +++ b/core/src/main/java/org/verapdf/processor/reports/multithread/writer/MrrReportWriter.java @@ -13,10 +13,10 @@ public class MrrReportWriter extends AbstractXmlReportWriter { private static final Logger LOGGER = Logger.getLogger(MrrReportWriter.class.getCanonicalName()); - private final String REPORT_TAG = "report"; - private final String BUILD_INFORMATION_TAG = "buildInformation"; - private final String JOBS_TAG = "jobs"; - private final String JOB_TAG = "job"; + private static final String REPORT_TAG = "report"; + private static final String BUILD_INFORMATION_TAG = "buildInformation"; + private static final String JOBS_TAG = "jobs"; + private static final String JOB_TAG = "job"; MrrReportWriter(PrintWriter outputStreamWriter, PrintWriter errorStreamWriter) throws XMLStreamException, ParserConfigurationException, SAXException { super(outputStreamWriter, errorStreamWriter); diff --git a/core/src/main/java/org/verapdf/processor/reports/multithread/writer/RawReportWriter.java b/core/src/main/java/org/verapdf/processor/reports/multithread/writer/RawReportWriter.java index 6bd7fe6db..cf325ac16 100644 --- a/core/src/main/java/org/verapdf/processor/reports/multithread/writer/RawReportWriter.java +++ b/core/src/main/java/org/verapdf/processor/reports/multithread/writer/RawReportWriter.java @@ -14,12 +14,12 @@ public class RawReportWriter extends AbstractXmlReportWriter { private static final Logger LOGGER = Logger.getLogger(RawReportWriter.class.getCanonicalName()); - private final String RAW_RESULTS_TAG = "rawResults"; - private final String ITEM_TAG = "item"; - private final String VALIDATION_RESULT_TAG = "validationResult"; - private final String PROCESSOR_CONFIG_TAG = "processorConfig"; - private final String FEATURES_REPORT_TAG = "featuresReport"; - private final String FIXER_RESULT_TAG = "fixerResult"; + private static final String RAW_RESULTS_TAG = "rawResults"; + private static final String ITEM_TAG = "item"; + private static final String VALIDATION_RESULT_TAG = "validationResult"; + private static final String PROCESSOR_CONFIG_TAG = "processorConfig"; + private static final String FEATURES_REPORT_TAG = "featuresReport"; + private static final String FIXER_RESULT_TAG = "fixerResult"; protected RawReportWriter(PrintWriter outputStreamWriter, PrintWriter errorStreamWriter) throws XMLStreamException, ParserConfigurationException, SAXException { super(outputStreamWriter, errorStreamWriter); diff --git a/core/src/main/java/org/verapdf/processor/reports/multithread/writer/ReportParserEventHandler.java b/core/src/main/java/org/verapdf/processor/reports/multithread/writer/ReportParserEventHandler.java index f29c4a9a0..803c5064c 100644 --- a/core/src/main/java/org/verapdf/processor/reports/multithread/writer/ReportParserEventHandler.java +++ b/core/src/main/java/org/verapdf/processor/reports/multithread/writer/ReportParserEventHandler.java @@ -15,19 +15,19 @@ public class ReportParserEventHandler extends DefaultHandler { private static final Logger LOGGER = Logger.getLogger(ReportParserEventHandler.class.getCanonicalName()); - private final Set BATCH_SUMMARY_TAGS = + private static final Set BATCH_SUMMARY_TAGS = new HashSet<>(Arrays.asList("batchSummary", "validationReports", "featureReports", "repairReports")); private String element; - private Map> batchSummary = new LinkedHashMap<>(); - private Map> current = new LinkedHashMap<>(); + private final Map> batchSummary = new LinkedHashMap<>(); + private final Map> current = new LinkedHashMap<>(); private boolean isPrinting = false; - private long startTime; + private final long startTime; private boolean isAddReportToSummary = false; - private XMLStreamWriter writer; + private final XMLStreamWriter writer; public ReportParserEventHandler(XMLStreamWriter writer) { this.writer = writer; @@ -36,12 +36,10 @@ public ReportParserEventHandler(XMLStreamWriter writer) { @Override public void endDocument() { - if (current.size() > 0) { - if (batchSummary.size() > 0) { - Set keySet = current.keySet(); - keySet.forEach(k -> { + if (!current.isEmpty()) { + if (!batchSummary.isEmpty()) { + current.forEach((k, currentAttributesAndValues) -> { Map summaryAttributesAndValues = batchSummary.get(k); - Map currentAttributesAndValues = current.get(k); currentAttributesAndValues.forEach((key, v) -> summaryAttributesAndValues.merge(key, v, Integer::sum)); }); } else { diff --git a/core/src/main/java/org/verapdf/processor/reports/multithread/writer/ReportWriter.java b/core/src/main/java/org/verapdf/processor/reports/multithread/writer/ReportWriter.java index 51c7bf817..c656b4153 100644 --- a/core/src/main/java/org/verapdf/processor/reports/multithread/writer/ReportWriter.java +++ b/core/src/main/java/org/verapdf/processor/reports/multithread/writer/ReportWriter.java @@ -11,9 +11,9 @@ public abstract class ReportWriter { private static final Logger LOGGER = Logger.getLogger(ReportWriter.class.getCanonicalName()); - protected PrintWriter outputStreamWriter; + protected final PrintWriter outputStreamWriter; - private PrintWriter errorStreamWriter; + private final PrintWriter errorStreamWriter; protected ReportWriter(PrintWriter outputStreamWriter, PrintWriter errorStreamWriter) { this.outputStreamWriter = outputStreamWriter; diff --git a/core/src/main/java/org/verapdf/report/FeaturesNode.java b/core/src/main/java/org/verapdf/report/FeaturesNode.java index 9bb8aa1f5..31d6522f3 100644 --- a/core/src/main/java/org/verapdf/report/FeaturesNode.java +++ b/core/src/main/java/org/verapdf/report/FeaturesNode.java @@ -161,7 +161,7 @@ private static String replaceInvalidCharacters(String source) { char curChar = source.charAt(i); if ('#' == curChar) { formatter.format("#x%06X", //$NON-NLS-1$ - Integer.valueOf("#".codePointAt(0))); //$NON-NLS-1$ + "#".codePointAt(0)); //$NON-NLS-1$ } else { int codePoint = source.codePointAt(i); if (Character.isHighSurrogate(curChar)) { @@ -172,14 +172,14 @@ private static String replaceInvalidCharacters(String source) { || (codePoint >= SP && codePoint <= XD7FF) || (codePoint >= XE000 && codePoint <= XFFFD) || (codePoint >= X10000 && codePoint <= X10FFFF)) { - formatter.format("%c", Character.valueOf(curChar)); //$NON-NLS-1$ + formatter.format("%c", curChar); //$NON-NLS-1$ if (Character.isHighSurrogate(curChar) && i < source.length()) { formatter.format("%c", //$NON-NLS-1$ - Character.valueOf(source.charAt(i))); + source.charAt(i)); } } else { - formatter.format("#x%06X", Integer.valueOf(codePoint)); //$NON-NLS-1$ + formatter.format("#x%06X", codePoint); //$NON-NLS-1$ } } } diff --git a/core/src/main/java/org/verapdf/report/FeaturesReport.java b/core/src/main/java/org/verapdf/report/FeaturesReport.java index 5edf8dd82..844ff614c 100644 --- a/core/src/main/java/org/verapdf/report/FeaturesReport.java +++ b/core/src/main/java/org/verapdf/report/FeaturesReport.java @@ -34,7 +34,7 @@ @XmlRootElement(name="featuresReport") public class FeaturesReport { - private final static String ERROR_STATUS = "Could not finish features collecting due to unexpected error."; //$NON-NLS-1$ + private static final String ERROR_STATUS = "Could not finish features collecting due to unexpected error."; //$NON-NLS-1$ @XmlElement private final String status; diff --git a/core/src/main/java/org/verapdf/version/VersionNumberImpl.java b/core/src/main/java/org/verapdf/version/VersionNumberImpl.java index 47f8f7f9a..b3cc44ced 100644 --- a/core/src/main/java/org/verapdf/version/VersionNumberImpl.java +++ b/core/src/main/java/org/verapdf/version/VersionNumberImpl.java @@ -38,8 +38,8 @@ private VersionNumberImpl(final String[] parts) { @Override public String getVersionString() { - return String.format("%d.%d.%d", Integer.valueOf(this.major), //$NON-NLS-1$ - Integer.valueOf(this.minor), Integer.valueOf(this.patch)); + return String.format("%d.%d.%d", this.major, //$NON-NLS-1$ + this.minor, this.patch); } @Override diff --git a/core/src/test/java/org/verapdf/ReleaseDetailsTest.java b/core/src/test/java/org/verapdf/ReleaseDetailsTest.java index bc20e8a7e..f7ce9540d 100644 --- a/core/src/test/java/org/verapdf/ReleaseDetailsTest.java +++ b/core/src/test/java/org/verapdf/ReleaseDetailsTest.java @@ -42,7 +42,7 @@ */ @SuppressWarnings("static-method") public class ReleaseDetailsTest { - private static String NAME = "verapdf-test"; + private static final String NAME = "verapdf-test"; @BeforeClass public static final void Before() { diff --git a/core/src/test/java/org/verapdf/model/impl/axl/XMPExtensionSchemaTest.java b/core/src/test/java/org/verapdf/model/impl/axl/XMPExtensionSchemaTest.java index 155803576..d54a6bf10 100644 --- a/core/src/test/java/org/verapdf/model/impl/axl/XMPExtensionSchemaTest.java +++ b/core/src/test/java/org/verapdf/model/impl/axl/XMPExtensionSchemaTest.java @@ -53,16 +53,16 @@ public static Collection data() { .asList(new Object[][] { { "org/verapdf/model/impl/axl/xmp-extension-schema-container-type-check-1.xml", - Boolean.TRUE, "pdfaExtension", Integer.valueOf(1)}, + Boolean.TRUE, "pdfaExtension", 1}, { "org/verapdf/model/impl/axl/xmp-extension-schema-container-type-check-2.xml", - Boolean.FALSE, "ext" , Integer.valueOf(1)}, + Boolean.FALSE, "ext" , 1}, { "org/verapdf/model/impl/axl/xmp-extension-schema-container-type-check-3.xml", - Boolean.FALSE, "pdfaExtension" , Integer.valueOf(1)}, + Boolean.FALSE, "pdfaExtension" , 1}, { "org/verapdf/model/impl/axl/xmp-extension-schema-container-type-check-4.xml", - Boolean.FALSE, "smth" , Integer.valueOf(0)} }); + Boolean.FALSE, "smth" , 0} }); } @Parameterized.Parameter @@ -93,15 +93,15 @@ public void test() throws URISyntaxException, XMPException, IOException { assertNotNull(linkedObjects); assertEquals(propertiesNumber, linkedObjects.size()); - if (linkedObjects.size() != 0) { + if (!linkedObjects.isEmpty()) { AXLExtensionSchemaDefinition definition = (AXLExtensionSchemaDefinition) linkedObjects.get(0); - assertFalse(definition.getcontainsUndefinedFields().booleanValue()); - assertTrue(definition.getisNamespaceURIValidURI().booleanValue()); - assertTrue(definition.getisPrefixValidText().booleanValue()); - assertTrue(definition.getisPropertyValidSeq().booleanValue()); - assertTrue(definition.getisSchemaValidText().booleanValue()); - assertTrue(definition.getisValueTypeValidSeq().booleanValue()); + assertFalse(definition.getcontainsUndefinedFields()); + assertTrue(definition.getisNamespaceURIValidURI()); + assertTrue(definition.getisPrefixValidText()); + assertTrue(definition.getisPropertyValidSeq()); + assertTrue(definition.getisSchemaValidText()); + assertTrue(definition.getisValueTypeValidSeq()); assertEquals("pdfaSchema", definition.getnamespaceURIPrefix()); assertEquals("pdfaSchema", definition.getprefixPrefix()); @@ -117,15 +117,15 @@ public void test() throws URISyntaxException, XMPException, IOException { assertNotNull(valueTypes); assertEquals(1, properties.size()); - if (properties.size() != 0) { + if (!properties.isEmpty()) { AXLExtensionSchemaProperty property = (AXLExtensionSchemaProperty) properties.get(0); - assertFalse(property.getcontainsUndefinedFields().booleanValue()); + assertFalse(property.getcontainsUndefinedFields()); assertEquals("external", property.getcategory()); - assertTrue(property.getisCategoryValidText().booleanValue()); - assertTrue(property.getisDescriptionValidText().booleanValue()); - assertTrue(property.getisNameValidText().booleanValue()); - assertTrue(property.getisValueTypeValidText().booleanValue()); - assertTrue(property.getisValueTypeDefined().booleanValue()); + assertTrue(property.getisCategoryValidText()); + assertTrue(property.getisDescriptionValidText()); + assertTrue(property.getisNameValidText()); + assertTrue(property.getisValueTypeValidText()); + assertTrue(property.getisValueTypeDefined()); assertEquals("pdfaProperty", property.getcategoryPrefix()); assertEquals("pdfaProperty", property.getvalueTypePrefix()); diff --git a/core/src/test/java/org/verapdf/model/impl/axl/XMPIdentificationTest.java b/core/src/test/java/org/verapdf/model/impl/axl/XMPIdentificationTest.java index 38332fc62..2b14dad72 100644 --- a/core/src/test/java/org/verapdf/model/impl/axl/XMPIdentificationTest.java +++ b/core/src/test/java/org/verapdf/model/impl/axl/XMPIdentificationTest.java @@ -49,18 +49,18 @@ public static Collection data() { .asList(new Object[][] { { "org/verapdf/model/impl/axl/xmp-identification-check-1.xml", - Integer.valueOf(1), Long.valueOf(1L), "B", + 1, 1L, "B", "pdfaid", "pdfaid", "pdfaid", "pdfaid" }, { "org/verapdf/model/impl/axl/xmp-identification-check-2.xml", - Integer.valueOf(1), Long.valueOf(2L), "U", + 1, 2L, "U", "custom", "custom", "custom", "custom" }, { "org/verapdf/model/impl/axl/xmp-identification-check-3.xml", - Integer.valueOf(1), null, null, "custom", null, + 1, null, null, "custom", null, "pdfaid", "pdfaid" }, { "org/verapdf/model/impl/axl/xmp-empty-rdf.xml", - Integer.valueOf(0), null, null, null, null, + 0, null, null, null, null, null, null } }); } @@ -97,7 +97,7 @@ public void test() throws URISyntaxException, XMPException, IOException { List list = pack .getLinkedObjects(AXLMainXMPPackage.IDENTIFICATION); assertEquals(this.identificationSchemaNumber, list.size()); - if (list.size() != 0) { + if (!list.isEmpty()) { AXLPDFAIdentification identification = (AXLPDFAIdentification) list .get(0); assertEquals(this.part, identification.getpart()); diff --git a/core/src/test/java/org/verapdf/model/impl/axl/XMPMMHistoryTest.java b/core/src/test/java/org/verapdf/model/impl/axl/XMPMMHistoryTest.java index ffa96e7be..c8454749f 100644 --- a/core/src/test/java/org/verapdf/model/impl/axl/XMPMMHistoryTest.java +++ b/core/src/test/java/org/verapdf/model/impl/axl/XMPMMHistoryTest.java @@ -51,15 +51,15 @@ public void test() throws URISyntaxException, XMPException, IOException { List list = pack .getLinkedObjects(AXLMainXMPPackage.PROPERTIES); assertEquals(1, list.size()); - if (list.size() != 0) { + if (!list.isEmpty()) { Object obj = list.get(0); assertTrue(obj instanceof AXLXMPMMHistoryProperty); AXLXMPMMHistoryProperty historyProperty = (AXLXMPMMHistoryProperty) obj; - assertTrue(historyProperty.getisValueTypeCorrect().booleanValue()); - assertTrue(historyProperty.getisPredefinedInXMP2004().booleanValue()); - assertTrue(historyProperty.getisPredefinedInXMP2005().booleanValue()); - assertFalse(historyProperty.getisDefinedInCurrentPackage().booleanValue()); - assertFalse(historyProperty.getisDefinedInMainPackage().booleanValue()); + assertTrue(historyProperty.getisValueTypeCorrect()); + assertTrue(historyProperty.getisPredefinedInXMP2004()); + assertTrue(historyProperty.getisPredefinedInXMP2005()); + assertFalse(historyProperty.getisDefinedInCurrentPackage()); + assertFalse(historyProperty.getisDefinedInMainPackage()); List resList = historyProperty .getLinkedObjects(AXLXMPMMHistoryProperty.RESOURCE_EVENTS); diff --git a/core/src/test/java/org/verapdf/model/impl/axl/XMPPropertiesNumberTest.java b/core/src/test/java/org/verapdf/model/impl/axl/XMPPropertiesNumberTest.java index 83eb94db9..2b8aa9a5d 100644 --- a/core/src/test/java/org/verapdf/model/impl/axl/XMPPropertiesNumberTest.java +++ b/core/src/test/java/org/verapdf/model/impl/axl/XMPPropertiesNumberTest.java @@ -48,16 +48,16 @@ public static Collection data() { .asList(new Object[][] { { "org/verapdf/model/impl/axl/xmp-properties-number-check-1.xml", - Integer.valueOf(4), Integer.valueOf(4) }, + 4, 4}, { "org/verapdf/model/impl/axl/xmp-properties-number-check-2.xml", - Integer.valueOf(3), Integer.valueOf(3) }, + 3, 3}, { "org/verapdf/model/impl/axl/xmp-properties-number-check-3.xml", - Integer.valueOf(3), Integer.valueOf(3) }, + 3, 3}, { "org/verapdf/model/impl/axl/xmp-properties-number-check-4.xml", - Integer.valueOf(2), Integer.valueOf(2) } }); + 2, 2} }); } @Parameterized.Parameter diff --git a/core/src/test/java/org/verapdf/pdfa/parsers/pkcs7/PKCS7Test.java b/core/src/test/java/org/verapdf/pdfa/parsers/pkcs7/PKCS7Test.java index cce4e88c9..a921e5f36 100644 --- a/core/src/test/java/org/verapdf/pdfa/parsers/pkcs7/PKCS7Test.java +++ b/core/src/test/java/org/verapdf/pdfa/parsers/pkcs7/PKCS7Test.java @@ -10,11 +10,11 @@ public class PKCS7Test { private PKCS7 parser; - String[] testPaths = new String[]{"src/test/resources/org/verapdf/pdfa/parsers/pkcs7/signed.txt", + final String[] testPaths = new String[]{"src/test/resources/org/verapdf/pdfa/parsers/pkcs7/signed.txt", "src/test/resources/org/verapdf/pdfa/parsers/pkcs7/signed2.txt", "src/test/resources/org/verapdf/pdfa/parsers/pkcs7/signed3.txt", "src/test/resources/org/verapdf/pdfa/parsers/pkcs7/signed4.txt"}; - int[] correctNumOfCert = new int[]{3, 1, 1, 1}; + final int[] correctNumOfCert = new int[]{3, 1, 1, 1}; @Test public void getSignerInfosLength() throws IOException { diff --git a/core/src/test/java/org/verapdf/pdfa/results/LocationTest.java b/core/src/test/java/org/verapdf/pdfa/results/LocationTest.java index c6d391916..c394b9a9c 100644 --- a/core/src/test/java/org/verapdf/pdfa/results/LocationTest.java +++ b/core/src/test/java/org/verapdf/pdfa/results/LocationTest.java @@ -35,7 +35,7 @@ */ @SuppressWarnings("static-method") public class LocationTest { - private final static String DEFAULT_LOCATION_STRING = "Location [level=level, context=context]"; //$NON-NLS-1$ + private static final String DEFAULT_LOCATION_STRING = "Location [level=level, context=context]"; //$NON-NLS-1$ /** * Test method for {@link org.verapdf.pdfa.results.LocationImpl#hashCode()}. diff --git a/core/src/test/java/org/verapdf/pdfa/results/ValidationResultTest.java b/core/src/test/java/org/verapdf/pdfa/results/ValidationResultTest.java index 383e1e9cd..36fc4765e 100644 --- a/core/src/test/java/org/verapdf/pdfa/results/ValidationResultTest.java +++ b/core/src/test/java/org/verapdf/pdfa/results/ValidationResultTest.java @@ -82,7 +82,7 @@ public final void testDefaultInstance() { */ @Test public final void testFromValues() { - ValidationResult resultFromVals = ValidationResults.resultFromValues(Profiles.defaultProfile(), Collections.emptyList(), false, JobEndStatus.NORMAL); + ValidationResult resultFromVals = ValidationResults.resultFromValues(Profiles.defaultProfile(), Collections.emptyList(), false, JobEndStatus.NORMAL); assertEquals(resultFromVals, ValidationResults.defaultResult()); assertNotSame(resultFromVals, ValidationResults.defaultResult()); } diff --git a/core/src/test/java/org/verapdf/pdfa/validation/profiles/ProfileDirectoryImplTest.java b/core/src/test/java/org/verapdf/pdfa/validation/profiles/ProfileDirectoryImplTest.java index 0a82050fd..d53726935 100644 --- a/core/src/test/java/org/verapdf/pdfa/validation/profiles/ProfileDirectoryImplTest.java +++ b/core/src/test/java/org/verapdf/pdfa/validation/profiles/ProfileDirectoryImplTest.java @@ -42,11 +42,11 @@ */ @SuppressWarnings("static-method") public class ProfileDirectoryImplTest { - private static ValidationProfile DEFAULT = Profiles.defaultProfile(); - private static ValidationProfile PDFA_1B = getPDFA1b(); - private static Set DEFAULT_ALONE = getSolitarySet(DEFAULT); - private static Set PDFA_1B_ALONE = getSolitarySet(PDFA_1B); - private static Set DUAL_PROFILE = getDualSet(); + private static final ValidationProfile DEFAULT = Profiles.defaultProfile(); + private static final ValidationProfile PDFA_1B = getPDFA1b(); + private static final Set DEFAULT_ALONE = getSolitarySet(DEFAULT); + private static final Set PDFA_1B_ALONE = getSolitarySet(PDFA_1B); + private static final Set DUAL_PROFILE = getDualSet(); /** * Test method for diff --git a/core/src/test/java/org/verapdf/pdfa/validation/profiles/ReferenceImplTest.java b/core/src/test/java/org/verapdf/pdfa/validation/profiles/ReferenceImplTest.java index b8717f317..619519506 100644 --- a/core/src/test/java/org/verapdf/pdfa/validation/profiles/ReferenceImplTest.java +++ b/core/src/test/java/org/verapdf/pdfa/validation/profiles/ReferenceImplTest.java @@ -34,7 +34,7 @@ */ @SuppressWarnings("static-method") public class ReferenceImplTest { - private final static String DEFAULT_REFERENCE_STRING = "Reference [specification=specification, clause=clause]"; + private static final String DEFAULT_REFERENCE_STRING = "Reference [specification=specification, clause=clause]"; /** * Test method for diff --git a/core/src/test/java/org/verapdf/pdfa/validation/profiles/RuleIdImplTest.java b/core/src/test/java/org/verapdf/pdfa/validation/profiles/RuleIdImplTest.java index 48bb17925..0936850b5 100644 --- a/core/src/test/java/org/verapdf/pdfa/validation/profiles/RuleIdImplTest.java +++ b/core/src/test/java/org/verapdf/pdfa/validation/profiles/RuleIdImplTest.java @@ -36,7 +36,7 @@ */ @SuppressWarnings("static-method") public class RuleIdImplTest { - private final static String DEFAULT_RULE_ID_STRING = "RuleId [specification=" + Specification.NO_STANDARD.toString() + ", clause=clause, testNumber=0]"; + private static final String DEFAULT_RULE_ID_STRING = "RuleId [specification=" + Specification.NO_STANDARD + ", clause=clause, testNumber=0]"; /** * Test method for {@link org.verapdf.pdfa.validation.profiles.RuleIdImpl#equals(java.lang.Object)}. */ diff --git a/core/src/test/java/org/verapdf/pdfa/validation/profiles/RuleImplTest.java b/core/src/test/java/org/verapdf/pdfa/validation/profiles/RuleImplTest.java index 1cfe75505..783fbeae2 100644 --- a/core/src/test/java/org/verapdf/pdfa/validation/profiles/RuleImplTest.java +++ b/core/src/test/java/org/verapdf/pdfa/validation/profiles/RuleImplTest.java @@ -74,7 +74,7 @@ public final void testFromValues() { // Get an equivalent to the default instance RuleImpl rule = RuleImpl .fromValues(Profiles.defaultRuleId(), "object", null, null, - "description", "test", ErrorDetailsImpl.defaultInstance(), Collections. emptyList()); + "description", "test", ErrorDetailsImpl.defaultInstance(), Collections.emptyList()); Rule defaultInstance = RuleImpl.defaultInstance(); // Equivalent is NOT the same object as default instance assertNotSame(rule, defaultInstance); diff --git a/core/src/test/java/org/verapdf/pdfa/validation/profiles/ValidationProfileImplTest.java b/core/src/test/java/org/verapdf/pdfa/validation/profiles/ValidationProfileImplTest.java index c3f83bf16..628e260c4 100644 --- a/core/src/test/java/org/verapdf/pdfa/validation/profiles/ValidationProfileImplTest.java +++ b/core/src/test/java/org/verapdf/pdfa/validation/profiles/ValidationProfileImplTest.java @@ -42,8 +42,8 @@ */ @SuppressWarnings("static-method") public class ValidationProfileImplTest { - private final static String DEFAULT_PROFILE_STRING = "ValidationProfile [flavour=" - + PDFAFlavour.NO_FLAVOUR.toString() + ", details=" + ProfileDetailsImpl.defaultInstance() + private static final String DEFAULT_PROFILE_STRING = "ValidationProfile [flavour=" + + PDFAFlavour.NO_FLAVOUR + ", details=" + ProfileDetailsImpl.defaultInstance() + ", hash=hash, rules=[], variables=[]]"; /** @@ -74,8 +74,8 @@ public final void testToString() { public final void testFromValues() { // Get an equivalent to the default instance ValidationProfile rule = Profiles.profileFromValues(PDFAFlavour.NO_FLAVOUR, - ProfileDetailsImpl.defaultInstance(), "hash", Collections.emptySet(), - Collections.emptySet()); + ProfileDetailsImpl.defaultInstance(), "hash", Collections.emptySet(), + Collections.emptySet()); ValidationProfile defaultInstance = Profiles.defaultProfile(); // Equivalent is NOT the same object as default instance assertNotSame(rule, defaultInstance); diff --git a/core/src/test/java/org/verapdf/pdfa/validation/profiles/VariableImplTest.java b/core/src/test/java/org/verapdf/pdfa/validation/profiles/VariableImplTest.java index dfee30fa5..91e2eccd4 100644 --- a/core/src/test/java/org/verapdf/pdfa/validation/profiles/VariableImplTest.java +++ b/core/src/test/java/org/verapdf/pdfa/validation/profiles/VariableImplTest.java @@ -38,7 +38,7 @@ */ @SuppressWarnings("static-method") public class VariableImplTest { - private final static String DEFAULT_VARIABLE_STRING = "Variable [name=name, object=object, defaultValue=defaultValue, value=value]"; + private static final String DEFAULT_VARIABLE_STRING = "Variable [name=name, object=object, defaultValue=defaultValue, value=value]"; /** * Test method for