Skip to content

Commit

Permalink
feat: notnull/internal annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
rushiiMachine committed Apr 17, 2022
1 parent c360750 commit 38aecac
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
1 change: 1 addition & 0 deletions lib/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ android {
isMinifyEnabled = false
}
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
Expand Down
5 changes: 5 additions & 0 deletions lib/src/main/java/com/github/diamondminer88/zip/ZipEntry.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
package com.github.diamondminer88.zip;

import org.jetbrains.annotations.ApiStatus.Internal;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

@SuppressWarnings("unused")
public class ZipEntry {
/**
* Internal pointer to ZipFile struct
*/
@Internal
private final long ptr = 0;

/**
Expand Down
15 changes: 10 additions & 5 deletions lib/src/main/java/com/github/diamondminer88/zip/ZipReader.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.github.diamondminer88.zip;

import org.jetbrains.annotations.ApiStatus.Internal;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand All @@ -15,22 +16,26 @@ public class ZipReader implements Closeable, Iterable<ZipEntry> {
System.loadLibrary("ziprs");
}

/**
* Internal pointer to ZipArchive struct
*/
@Internal
@SuppressWarnings("FieldMayBeFinal")
private long ptr = 0;

/**
* Open a zip file with readonly operations
* @param path Path to the archive
*/
public ZipReader(String path) {
public ZipReader(@NotNull String path) {
open(path);
}

/**
* Open a zip with readonly operations
* @param file File of the archive
*/
public ZipReader(File file) {
public ZipReader(@NotNull File file) {
open(file.getAbsolutePath());
}

Expand Down Expand Up @@ -58,7 +63,7 @@ public ZipReader(File file) {
* @param path Path to the file inside the archive.
*/
@Nullable
public native ZipEntry openEntry(String path);
public native ZipEntry openEntry(@NotNull String path);

/**
* Get a contained file by index without decompressing it.
Expand Down Expand Up @@ -94,8 +99,8 @@ public String getComment() {
}

/**
* Get an iterator for all the entries contained in this archive.
* Decompresses data when entry read.
* Iterate over all the entries contained in this archive.
* Opens entry with decompressing.
*/
@NotNull
@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.github.diamondminer88.zip;

import org.jetbrains.annotations.ApiStatus.Internal;

import java.io.Closeable;
import java.io.File;
import java.nio.charset.StandardCharsets;
Expand All @@ -10,6 +12,10 @@ public class ZipWriter implements Closeable {
System.loadLibrary("ziprs");
}

/**
* Internal pointer to ZipWriter struct
*/
@Internal
@SuppressWarnings("FieldMayBeFinal")
private long ptr = 0;

Expand Down Expand Up @@ -112,7 +118,7 @@ public void writeEntry(String path, String content) {
public native void deleteEntries(String... entries);

/**
* Finalizes the archive and saves to disk.
* Finalizes the writer and saves to disk.
* You cannot use this ZipWriter instance after closing it.
*/
@Override
Expand Down

0 comments on commit 38aecac

Please sign in to comment.