From 86c2bcebff8819a6cc567c5e75761d6dadda141e Mon Sep 17 00:00:00 2001 From: Tyler Gregg Date: Fri, 11 Oct 2024 15:40:54 -0700 Subject: [PATCH] Marks Kotlin classes internal where possible. --- src/main/java/com/amazon/ion/impl/EncodingDirectiveReader.kt | 2 +- src/main/java/com/amazon/ion/impl/IonReaderTextSystemX.java | 2 +- src/main/java/com/amazon/ion/impl/macro/MacroCompiler.kt | 2 +- src/main/java/com/amazon/ion/impl/macro/ReaderAdapter.kt | 4 +++- .../com/amazon/ion/impl/macro/ReaderAdapterContinuable.kt | 2 +- .../java/com/amazon/ion/impl/macro/ReaderAdapterIonReader.kt | 2 +- src/test/java/com/amazon/ion/impl/macro/MacroCompilerTest.kt | 2 +- 7 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/amazon/ion/impl/EncodingDirectiveReader.kt b/src/main/java/com/amazon/ion/impl/EncodingDirectiveReader.kt index f356d565d..041942b98 100644 --- a/src/main/java/com/amazon/ion/impl/EncodingDirectiveReader.kt +++ b/src/main/java/com/amazon/ion/impl/EncodingDirectiveReader.kt @@ -15,7 +15,7 @@ import com.amazon.ion.impl.macro.MacroRef.Companion.byName * IonReaderContinuableCoreBinary.EncodingDirectiveReader should be moved to the top level and shared by both readers. * If that were to happen, this class would no longer be needed. */ -class EncodingDirectiveReader(private val reader: IonReader, readerAdapter: ReaderAdapter) { +internal class EncodingDirectiveReader(private val reader: IonReader, readerAdapter: ReaderAdapter) { private var macroCompiler: MacroCompiler = MacroCompiler({ key: Any? -> newMacros[key] }, readerAdapter) private var localMacroMaxOffset: Int = -1 diff --git a/src/main/java/com/amazon/ion/impl/IonReaderTextSystemX.java b/src/main/java/com/amazon/ion/impl/IonReaderTextSystemX.java index 608d85e90..f396ea059 100644 --- a/src/main/java/com/amazon/ion/impl/IonReaderTextSystemX.java +++ b/src/main/java/com/amazon/ion/impl/IonReaderTextSystemX.java @@ -730,7 +730,7 @@ public final int getFieldId() id = getFieldNameSymbol().getSid(); } else { // Superclass handles hoisting logic - id =super.getFieldId(); + id = super.getFieldId(); } if (id == SymbolTable.UNKNOWN_SYMBOL_ID) { diff --git a/src/main/java/com/amazon/ion/impl/macro/MacroCompiler.kt b/src/main/java/com/amazon/ion/impl/macro/MacroCompiler.kt index 3320baff7..d31fbeb57 100644 --- a/src/main/java/com/amazon/ion/impl/macro/MacroCompiler.kt +++ b/src/main/java/com/amazon/ion/impl/macro/MacroCompiler.kt @@ -12,7 +12,7 @@ import com.amazon.ion.util.confirm * [MacroCompiler] wraps an Ion reader. When directed to do so, it will take over advancing and getting values from the * reader in order to read one [TemplateMacro]. */ -class MacroCompiler( +internal class MacroCompiler( private val getMacro: (MacroRef) -> Macro?, private val reader: ReaderAdapter ) { diff --git a/src/main/java/com/amazon/ion/impl/macro/ReaderAdapter.kt b/src/main/java/com/amazon/ion/impl/macro/ReaderAdapter.kt index a4f7ee63e..2b12e769b 100644 --- a/src/main/java/com/amazon/ion/impl/macro/ReaderAdapter.kt +++ b/src/main/java/com/amazon/ion/impl/macro/ReaderAdapter.kt @@ -1,3 +1,5 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 package com.amazon.ion.impl.macro import com.amazon.ion.* @@ -9,7 +11,7 @@ import java.math.BigInteger * @see ReaderAdapterIonReader * @see ReaderAdapterContinuable */ -interface ReaderAdapter { +internal interface ReaderAdapter { fun hasAnnotations(): Boolean fun fieldNameSymbol(): SymbolToken diff --git a/src/main/java/com/amazon/ion/impl/macro/ReaderAdapterContinuable.kt b/src/main/java/com/amazon/ion/impl/macro/ReaderAdapterContinuable.kt index c96f68146..9bf72f9d9 100644 --- a/src/main/java/com/amazon/ion/impl/macro/ReaderAdapterContinuable.kt +++ b/src/main/java/com/amazon/ion/impl/macro/ReaderAdapterContinuable.kt @@ -10,7 +10,7 @@ import java.math.BigInteger /** * A [ReaderAdapter] that wraps an [IonReaderContinuableCore]. */ -class ReaderAdapterContinuable(val reader: IonReaderContinuableCore) : ReaderAdapter { +internal class ReaderAdapterContinuable(val reader: IonReaderContinuableCore) : ReaderAdapter { // TODO: Make sure that we can throw exceptions if there's an over-sized value. diff --git a/src/main/java/com/amazon/ion/impl/macro/ReaderAdapterIonReader.kt b/src/main/java/com/amazon/ion/impl/macro/ReaderAdapterIonReader.kt index 49c6c2ec4..d49dfed67 100644 --- a/src/main/java/com/amazon/ion/impl/macro/ReaderAdapterIonReader.kt +++ b/src/main/java/com/amazon/ion/impl/macro/ReaderAdapterIonReader.kt @@ -9,7 +9,7 @@ import java.math.BigInteger /** * A [ReaderAdapter] that wraps an [IonReader]. */ -class ReaderAdapterIonReader(val reader: IonReader) : ReaderAdapter { +internal class ReaderAdapterIonReader(val reader: IonReader) : ReaderAdapter { // TODO performance: when there are annotations, this causes a redundant allocation if the allocations are // later consumed. diff --git a/src/test/java/com/amazon/ion/impl/macro/MacroCompilerTest.kt b/src/test/java/com/amazon/ion/impl/macro/MacroCompilerTest.kt index fdcae9bbd..59a46a582 100644 --- a/src/test/java/com/amazon/ion/impl/macro/MacroCompilerTest.kt +++ b/src/test/java/com/amazon/ion/impl/macro/MacroCompilerTest.kt @@ -172,7 +172,7 @@ class MacroCompilerTest { } }; - abstract fun newMacroCompiler(reader: IonReader, macros: ((MacroRef) -> Macro?)): MacroCompiler + internal abstract fun newMacroCompiler(reader: IonReader, macros: ((MacroRef) -> Macro?)): MacroCompiler } private fun newReader(source: String): IonReader {