start of filesystem impl conversion to kotlin#358
start of filesystem impl conversion to kotlin#358brianPlummer wants to merge 7 commits intofeature/kotlin_conversionfrom
Conversation
| import io.reactivex.Observable | ||
|
|
||
|
|
||
| class FSAllEraser(internal val fileSystem: FileSystem) : DiskAllErase { |
There was a problem hiding this comment.
Not sure if this was intended to have package level visibility in the previous implementation, put it can be private I think!
| * Make sure to have keys containing same data resolve to same "path" | ||
| * @param <T> key type | ||
| </T> */ | ||
| open class FSWriter<T>(internal val fileSystem: FileSystem, internal val pathResolver: PathResolver<T>) : DiskWrite<BufferedSource, T> { |
There was a problem hiding this comment.
Same here it can be private I think!
| open class FSWriter<T>(internal val fileSystem: FileSystem, internal val pathResolver: PathResolver<T>) : DiskWrite<BufferedSource, T> { | ||
|
|
||
| override fun write(key: T, data: BufferedSource): Single<Boolean> { | ||
| return Single.fromCallable { |
There was a problem hiding this comment.
You can lift it to assignment!
|
|
||
| class FSAllEraser(internal val fileSystem: FileSystem) : DiskAllErase { | ||
| override fun deleteAll(path: String): Observable<Boolean> { | ||
| return Observable.fromCallable { |
There was a problem hiding this comment.
You can lift it to assignment!
| fun create(fileSystem: FileSystem, | ||
| expirationDuration: Long, | ||
| expirationUnit: TimeUnit): RecordPersister { | ||
| return RecordPersister(fileSystem, expirationDuration, expirationUnit) |
There was a problem hiding this comment.
You can lift it to assignment!
| class SourceAllPersister @Inject | ||
| constructor(fileSystem: FileSystem) : AllPersister<BufferedSource, BarCode> { | ||
|
|
||
| internal val sourceFileAllReader: FSAllReader |
There was a problem hiding this comment.
All these vals can be private and by lazy :)
| fun getRecordState(barCode: BarCode, | ||
| expirationUnit: TimeUnit, | ||
| expirationDuration: Long): RecordState { | ||
| return fileSystem.getRecordState(expirationUnit, expirationDuration, SourcePersister.pathForBarcode(barCode)) |
There was a problem hiding this comment.
You can lift it to assignment!
|
|
||
| @Throws(FileNotFoundException::class) | ||
| override fun readAll(path: String): Observable<BufferedSource> { | ||
| return sourceFileAllReader.readAll(path) |
There was a problem hiding this comment.
You can lift it to assignment! Similarly on the following methods!
| open class SourcePersister @Inject | ||
| constructor(fileSystem: FileSystem) : Persister<BufferedSource, BarCode> { | ||
|
|
||
| internal val sourceFileReader: SourceFileReader |
There was a problem hiding this comment.
Can be private and by lazy previously!
| throw new IllegalArgumentException("root file cannot be null."); | ||
| } | ||
| return RecordPersister.create(FileSystemFactory.create(root), expirationDuration, expirationUnit); | ||
| return RecordPersister.Companion.create(FileSystemFactory.create(root), expirationDuration, expirationUnit); |
There was a problem hiding this comment.
You can mark .create() with @JvmStatic if this is going to remain a Java file.
There was a problem hiding this comment.
i did not know that! thanks! :) i'm trying to keep the pr's small for the moment :) so i'm converting in batches.
No description provided.