Skip to content

Commit 48aa0fd

Browse files
committed
Fix javadoc warnings and class visibility, fix licence warnings
1 parent 6b40d0b commit 48aa0fd

37 files changed

+571
-195
lines changed

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@
139139
<excludes>
140140
<exclude>LICENSE.txt</exclude>
141141
<exclude>**/*.md</exclude>
142+
<exclude>**/*.csv</exclude>
142143
<exclude>lmdb/**</exclude>
143144
<exclude>licenses/**</exclude>
144145
</excludes>

src/main/java/org/lmdbjava/AbstractFlagSet.java

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@
2424
import java.util.function.Function;
2525
import java.util.function.Supplier;
2626

27-
/** Encapsulates an immutable set of flags and the associated bit mask for the flags in the set. */
28-
public abstract class AbstractFlagSet<T extends Enum<T> & MaskedFlag> implements FlagSet<T> {
27+
/** Encapsulates an immutable set of flags and the associated bit mask for the flags in the set.
28+
* @param <T> The type of the flags in this set. Must extend {@link MaskedFlag} and {@link Enum<T>}.
29+
* */
30+
abstract class AbstractFlagSet<T extends Enum<T> & MaskedFlag> implements FlagSet<T> {
2931

3032
private final Set<T> flags;
3133
private final int mask;
@@ -36,25 +38,16 @@ protected AbstractFlagSet(final EnumSet<T> flags) {
3638
this.flags = Collections.unmodifiableSet(Objects.requireNonNull(flags));
3739
}
3840

39-
/**
40-
* @return THe combined bit mask for all flags in the set.
41-
*/
4241
@Override
4342
public int getMask() {
4443
return mask;
4544
}
4645

47-
/**
48-
* @return All flags in the set.
49-
*/
5046
@Override
5147
public Set<T> getFlags() {
5248
return flags;
5349
}
5450

55-
/**
56-
* @return True if flag has been set, i.e. is contained in this set.
57-
*/
5851
@Override
5952
public boolean isSet(final T flag) {
6053
// Probably cheaper to compare the masks than to use EnumSet.contains()
@@ -163,11 +156,6 @@ public String toString() {
163156
return FlagSet.asString(this);
164157
}
165158

166-
@Override
167-
public boolean equals(Object object) {
168-
return FlagSet.equals(this, object);
169-
}
170-
171159
@Override
172160
public int hashCode() {
173161
return Objects.hash(flag, getFlags());
@@ -239,15 +227,15 @@ public int hashCode() {
239227
* @param <E> The type of flag to be held in the {@link AbstractFlagSet}
240228
* @param <S> The type of the {@link AbstractFlagSet} implementation.
241229
*/
242-
public static class Builder<E extends Enum<E> & MaskedFlag, S extends FlagSet<E>> {
230+
public static final class Builder<E extends Enum<E> & MaskedFlag, S extends FlagSet<E>> {
243231

244232
final Class<E> type;
245233
final EnumSet<E> enumSet;
246234
final Function<EnumSet<E>, S> constructor;
247235
final Function<E, S> singletonSetConstructor;
248236
final Supplier<S> emptySetSupplier;
249237

250-
protected Builder(
238+
Builder(
251239
final Class<E> type,
252240
final Function<EnumSet<E>, S> constructor,
253241
final Function<E, S> singletonSetConstructor,
@@ -279,6 +267,7 @@ public Builder<E, S> setFlags(final Collection<E> flags) {
279267
}
280268

281269
/**
270+
* Replaces any flags already set in the builder with the passed flags.
282271
* @param flags The flags to set in the builder.
283272
* @return this builder instance.
284273
*/

src/main/java/org/lmdbjava/ByteUnit.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@
1717

1818
/** Simple {@link Enum} for converting various IEC and SI byte units down a number of bytes. */
1919
public enum ByteUnit {
20+
21+
/** IEC/SI byte unit for bytes. */
2022
BYTES(1L),
2123

2224
/** IEC byte unit for 1024 bytes. */
23-
KIBIBYTES(1024L),
25+
KIBIBYTES(1_024L),
2426
/** IEC byte unit for 1024^2 bytes. */
25-
MEBIBYTES(1_0485_76L),
27+
MEBIBYTES(1_048_576L),
2628
/** IEC byte unit for 1024^3 bytes. */
2729
GIBIBYTES(1_073_741_824L),
2830
/** IEC byte unit for 1024^4 bytes. */
@@ -59,6 +61,7 @@ public long toBytes(final long value) {
5961
}
6062

6163
/**
64+
* Gets factor to apply when converting this unit into bytes.
6265
* @return The factor to apply when converting this unit into bytes.
6366
*/
6467
public long getFactor() {

src/main/java/org/lmdbjava/CopyFlagSet.java

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,45 +15,60 @@
1515
*/
1616
package org.lmdbjava;
1717

18+
import java.nio.file.Path;
1819
import java.util.Collection;
19-
import java.util.EnumSet;
2020
import java.util.Objects;
2121

22+
/** An immutable set of flags for use when performing a {@link Env#copy(Path, CopyFlagSet)}. */
2223
public interface CopyFlagSet extends FlagSet<CopyFlags> {
2324

25+
/**
26+
* An immutable empty {@link CopyFlagSet}.
27+
*/
2428
CopyFlagSet EMPTY = CopyFlagSetImpl.EMPTY;
2529

30+
/**
31+
* Gets the immutable empty {@link CopyFlagSet} instance.
32+
* @return The immutable empty {@link CopyFlagSet} instance.
33+
*/
2634
static CopyFlagSet empty() {
2735
return CopyFlagSetImpl.EMPTY;
2836
}
2937

30-
static CopyFlagSet of(final CopyFlags dbiFlag) {
31-
Objects.requireNonNull(dbiFlag);
32-
return dbiFlag;
38+
/**
39+
* Creates an immutable {@link CopyFlagSet} containing copyFlag.
40+
* @param copyFlag The flag to include in the {@link CopyFlagSet}
41+
* @return An immutable {@link CopyFlagSet} containing just copyFlag.
42+
*/
43+
static CopyFlagSet of(final CopyFlags copyFlag) {
44+
Objects.requireNonNull(copyFlag);
45+
return copyFlag;
3346
}
3447

35-
static CopyFlagSet of(final CopyFlags... CopyFlags) {
36-
return builder().setFlags(CopyFlags).build();
48+
/**
49+
* Creates an immutable {@link CopyFlagSet} containing copyFlags.
50+
* @param copyFlags The flags to include in the {@link CopyFlagSet}.
51+
* @return An immutable {@link CopyFlagSet} containing copyFlags.
52+
*/
53+
static CopyFlagSet of(final CopyFlags... copyFlags) {
54+
return builder().setFlags(copyFlags).build();
3755
}
3856

39-
static CopyFlagSet of(final Collection<CopyFlags> CopyFlags) {
40-
return builder().setFlags(CopyFlags).build();
57+
/**
58+
* Creates an immutable {@link CopyFlagSet} containing copyFlags.
59+
* @param copyFlags The flags to include in the {@link CopyFlagSet}.
60+
* @return An immutable {@link CopyFlagSet} containing copyFlags.
61+
*/
62+
static CopyFlagSet of(final Collection<CopyFlags> copyFlags) {
63+
return builder().setFlags(copyFlags).build();
4164
}
4265

66+
/**
67+
* Create a builder for building an {@link CopyFlagSet}.
68+
* @return A builder instance for building an {@link CopyFlagSet}.
69+
*/
4370
static AbstractFlagSet.Builder<CopyFlags, CopyFlagSet> builder() {
4471
return new AbstractFlagSet.Builder<>(
4572
CopyFlags.class, CopyFlagSetImpl::new, copyFlag -> copyFlag, () -> CopyFlagSetImpl.EMPTY);
4673
}
47-
48-
class CopyFlagSetImpl extends AbstractFlagSet<CopyFlags> implements CopyFlagSet {
49-
50-
static final CopyFlagSet EMPTY = new EmptyCopyFlagSet();
51-
52-
private CopyFlagSetImpl(final EnumSet<CopyFlags> flags) {
53-
super(flags);
54-
}
55-
}
56-
57-
class EmptyCopyFlagSet extends AbstractFlagSet.AbstractEmptyFlagSet<CopyFlags>
58-
implements CopyFlagSet {}
5974
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright © 2016-2025 The LmdbJava Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.lmdbjava;
17+
18+
class CopyFlagSetEmpty extends AbstractFlagSet.AbstractEmptyFlagSet<CopyFlags>
19+
implements CopyFlagSet {
20+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright © 2016-2025 The LmdbJava Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.lmdbjava;
17+
18+
import java.util.EnumSet;
19+
20+
class CopyFlagSetImpl extends AbstractFlagSet<CopyFlags> implements CopyFlagSet {
21+
22+
static final CopyFlagSet EMPTY = new CopyFlagSetEmpty();
23+
24+
CopyFlagSetImpl(final EnumSet<CopyFlags> flags) {
25+
super(flags);
26+
}
27+
}

src/main/java/org/lmdbjava/CopyFlags.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
*/
1616
package org.lmdbjava;
1717

18-
import java.io.File;
18+
import java.nio.file.Path;
1919
import java.util.EnumSet;
2020
import java.util.Set;
2121

22-
/** Flags for use when performing a {@link Env#copy(File, CopyFlagSet)}. */
22+
/** Flags for use when performing a {@link Env#copy(Path, CopyFlagSet)}. */
2323
public enum CopyFlags implements MaskedFlag, CopyFlagSet {
2424

2525
/** Compacting copy: Omit free space from copy, and renumber all pages sequentially. */

src/main/java/org/lmdbjava/Dbi.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,19 +271,24 @@ public T get(final Txn<T> txn, final T key) {
271271
/**
272272
* Obtains the name of this database.
273273
*
274-
* @return the name (may be null)
274+
* @return The name (it maybe null)
275275
*/
276276
public byte[] getName() {
277277
return name == null ? null : Arrays.copyOf(name, name.length);
278278
}
279279

280+
/**
281+
* Obtains the name of this database, using the {@link Env#DEFAULT_NAME_CHARSET} {@link Charset}.
282+
* @return The name of this database, using the {@link Env#DEFAULT_NAME_CHARSET} {@link Charset}.
283+
*/
280284
public String getNameAsString() {
281285
return getNameAsString(Env.DEFAULT_NAME_CHARSET);
282286
}
283287

284288
/**
285289
* Obtains the name of this database, using the supplied {@link Charset}.
286290
*
291+
* @param charset The {@link Charset} to use when converting the DB from a byte[] to a {@link String}.
287292
* @return The name of the database. If this is the unnamed database an empty string will be
288293
* returned.
289294
* @throws RuntimeException if the name can't be decoded.

0 commit comments

Comments
 (0)