Question

In the LongBinding class, the methods entryToLong(DatabaseEntry entry) and longToEntry(long val, DatabaseEntry entry) are both static.

But in the ByteArrayBinding class, entryToObject(DatabaseEntry entry) and objectToEntry(byte[] object, DatabaseEntry entry) are both not static.

The implementations of these methods seem very similar. For example, upon examining the source code, one can see that both the longToEntry and objectToEntry methods are delegating to entry.setData, where entry is a method parameter with type DatabaseEntry.

Why are these two LongBinding methods static, while the analogous ByteArrayBinding methods are not?

In my pom.xml, I have the following dependency:

<dependency>
  <groupId>com.sleepycat</groupId>
  <artifactId>je</artifactId>
  <version>4.1.21</version>
</dependency>
Était-ce utile?

La solution

There is not really an explanation.

The methods in ByteArrayBinding could (and should?) have been static as they have no reference to the instance of the class.

Those two classes have probably been written by different developpers and they implemented the functionality a bit differently.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top