Skip to content
This repository was archived by the owner on Sep 1, 2024. It is now read-only.

Commit ec75653

Browse files
committed
Javadoc added
1 parent d8eb62f commit ec75653

10 files changed

Lines changed: 125 additions & 32 deletions

File tree

eu.dariolucia.reatmetric.api/src/main/java/eu/dariolucia/reatmetric/api/activity/IActivityOccurrenceDataArchive.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,6 @@
1717
package eu.dariolucia.reatmetric.api.activity;
1818

1919
import eu.dariolucia.reatmetric.api.archive.IDataItemArchive;
20-
import eu.dariolucia.reatmetric.api.archive.exceptions.ArchiveException;
21-
import eu.dariolucia.reatmetric.api.events.EventData;
22-
import eu.dariolucia.reatmetric.api.events.EventDataFilter;
23-
24-
import java.time.Instant;
25-
import java.util.List;
2620

2721
/**
2822
* This interface is a specialisation of the {@link IDataItemArchive}, for activity occurrences.

eu.dariolucia.reatmetric.api/src/main/java/eu/dariolucia/reatmetric/api/alarms/IAlarmParameterDataArchive.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
package eu.dariolucia.reatmetric.api.alarms;
1818

1919
import eu.dariolucia.reatmetric.api.archive.IDataItemArchive;
20-
import eu.dariolucia.reatmetric.api.parameters.ParameterData;
21-
import eu.dariolucia.reatmetric.api.parameters.ParameterDataFilter;
2220

2321
/**
2422
* This interface is a specialisation of the {@link IDataItemArchive}, for parameter alarms.

eu.dariolucia.reatmetric.api/src/main/java/eu/dariolucia/reatmetric/api/archive/IArchive.java

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,36 @@
1919
import eu.dariolucia.reatmetric.api.archive.exceptions.ArchiveException;
2020
import eu.dariolucia.reatmetric.api.common.AbstractDataItem;
2121
import eu.dariolucia.reatmetric.api.common.AbstractDataItemFilter;
22-
import eu.dariolucia.reatmetric.api.events.IEventDataArchive;
23-
import eu.dariolucia.reatmetric.api.messages.IOperationalMessageArchive;
24-
import eu.dariolucia.reatmetric.api.parameters.IParameterDataArchive;
25-
import eu.dariolucia.reatmetric.api.rawdata.IRawDataArchive;
2622

23+
/**
24+
* This interface specifies the entry point contract for archive service providers.
25+
*/
2726
public interface IArchive {
2827

28+
/**
29+
* Connect to the archive backend system. The archive can be used only after return from this invocation.
30+
*
31+
* @throws ArchiveException in case of problems connecting to the archive backend system
32+
*/
2933
void connect() throws ArchiveException;
3034

35+
/**
36+
* Close the connection to the archive backend system. After this call, the object should be no longer be used.
37+
*
38+
* @throws ArchiveException in case of problems disconnecting to the archive backend system
39+
*/
3140
void dispose() throws ArchiveException;
3241

33-
<U extends IDataItemArchive<J,K>,J extends AbstractDataItem,K extends AbstractDataItemFilter> U getArchive(Class<U> clazz);
42+
/**
43+
* Retrieve the {@link IDataItemArchive} implementation specified by parameter clazz. This method is allowed
44+
* to return null, if no implementation of the requested interface is available, so callers should check the return
45+
* value.
46+
*
47+
* @param clazz the type class of the {@link IDataItemArchive}
48+
* @param <U> the type class of clazz
49+
* @param <J> the {@link AbstractDataItem} type managed by the specified archive interface clazz
50+
* @param <K> the {@link AbstractDataItemFilter} type managed by the specified archive interface clazz
51+
* @return the implementation of the requested {@link IDataItemArchive} type or null if such implementation is not available
52+
*/
53+
<U extends IDataItemArchive<J,K>,J extends AbstractDataItem,K extends AbstractDataItemFilter<J>> U getArchive(Class<U> clazz);
3454
}

eu.dariolucia.reatmetric.api/src/main/java/eu/dariolucia/reatmetric/api/archive/IArchiveFactory.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,25 @@
1818

1919
import eu.dariolucia.reatmetric.api.archive.exceptions.ArchiveException;
2020

21+
/**
22+
* This interface is the service interface representing the persistence service in a ReatMetric system. It contains
23+
* a single factory method that can be used to instantiate an implementation of the {@link IArchive} interface.
24+
*/
2125
public interface IArchiveFactory {
2226

27+
/**
28+
* Return an implementation of the {@link IArchive} interface supplied by the provider of the service. The
29+
* archiveLocation parameter type and format depends on the archive specific implementation, i.e. can be a
30+
* JDBC string, a file path containing a configuration, an IP address. From this string, the specific implementation
31+
* shall be able to construct and return an object.
32+
*
33+
* The returned {@link IArchive} object is not required to be a different new object: {@link IArchiveFactory}
34+
* implementations are allowed to cache objects or use a singleton-based design.
35+
*
36+
* @param archiveLocation the 'location' of the archive
37+
* @return an implementation of {@link IArchive} interface
38+
* @throws ArchiveException in case of problems arising from the construction of the specific {@link IArchive} object
39+
*/
2340
IArchive buildArchive(String archiveLocation) throws ArchiveException;
2441

2542
}

eu.dariolucia.reatmetric.api/src/main/java/eu/dariolucia/reatmetric/api/archive/IDataItemArchive.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
* @param <T> the {@link AbstractDataItem} that this service stores/retrieves
3232
* @param <K> the {@link AbstractDataItemFilter} that can be used with this service
3333
*/
34-
public interface IDataItemArchive<T extends AbstractDataItem, K extends AbstractDataItemFilter> {
34+
public interface IDataItemArchive<T extends AbstractDataItem, K extends AbstractDataItemFilter<T>> {
3535

3636
/**
3737
* Retrieve a maximum of numRecords data items, with a generation time greater/lower or equals than the provided startTime (if

eu.dariolucia.reatmetric.api/src/main/java/eu/dariolucia/reatmetric/api/archive/exceptions/ArchiveException.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818

1919
import eu.dariolucia.reatmetric.api.common.exceptions.ReatmetricException;
2020

21+
/**
22+
* Exception class for usage in the archive-related operations.
23+
*/
2124
public class ArchiveException extends ReatmetricException {
2225

2326
/**

eu.dariolucia.reatmetric.api/src/main/java/eu/dariolucia/reatmetric/api/common/AbstractDataItem.java

Lines changed: 43 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,42 +17,68 @@
1717

1818
import java.io.Serializable;
1919
import java.time.Instant;
20-
import java.util.Arrays;
2120
import java.util.Objects;
2221

2322
/**
23+
* This class is the base class for all data items managed and stored by the ReatMetric infrastructure. Such items
24+
* are characterized by having a generation time and an extension object, that can be serialized and stored.
2425
*
25-
* @author dario
26+
* Being a derivation from the {@link UniqueItem} class, objects of this class have an internal ID, which is unique
27+
* among all the object instances of the same class type.
28+
*
29+
* Objects of this class are supposed to be immutable. In particular, the extension object, when used, must be immutable
30+
* or not modified, as soon as provided in the object constructor. This means, exclusive ownership to modify the object
31+
* shall be transferred to the {@link AbstractDataItem} object. Failing to do so may result in undefined behaviour
32+
* during the handling and storage of the instance.
2633
*/
2734
public abstract class AbstractDataItem extends UniqueItem implements Serializable {
2835

2936
/**
3037
*
3138
*/
32-
private static final long serialVersionUID = -7442923730308757888L;
39+
private static final long serialVersionUID = 1L;
3340

3441
protected final Object extension;
3542

3643
protected final Instant generationTime;
37-
44+
45+
/**
46+
* Constructor of the object. If null generation time is provided, the object generation time is set to
47+
* Instant.EPOCH.
48+
*
49+
* @param internalId the unique internal ID that identifies this specific instance
50+
* @param generationTime the generation time - if set to null, Instant.EPOCH is used
51+
* @param extension the extension object (can be null)
52+
*/
3853
public AbstractDataItem(IUniqueId internalId, Instant generationTime, Object extension) {
3954
super(internalId, null);
40-
if(generationTime != null) {
41-
this.generationTime = generationTime;
42-
} else {
43-
this.generationTime = Instant.EPOCH;
44-
}
55+
this.generationTime = Objects.requireNonNullElse(generationTime, Instant.EPOCH);
4556
this.extension = extension;
4657
}
4758

59+
/**
60+
* Return the data item generation time.
61+
*
62+
* @return the generation time (cannot be null)
63+
*/
4864
public Instant getGenerationTime() {
4965
return generationTime;
5066
}
5167

68+
/**
69+
* Return the extension object that was specified in the constructor.
70+
*
71+
* @return the extension object (can be null)
72+
*/
5273
public Object getExtension() {
5374
return extension;
5475
}
5576

77+
/**
78+
* The hashcode defined by this object takes into account only the internal ID and the generation time fields.
79+
*
80+
* @return the object hashcode
81+
*/
5682
@Override
5783
public int hashCode() {
5884
int hash = 5;
@@ -61,6 +87,13 @@ public int hashCode() {
6187
return hash;
6288
}
6389

90+
/**
91+
* The equality defined by this object is based on the class type, the equality of the internal ID and the
92+
* equality of the generation time.
93+
*
94+
* @param obj the object, to check equality against
95+
* @return true if obj is equal to this, otherwise false
96+
*/
6497
@Override
6598
public boolean equals(Object obj) {
6699
if (this == obj) {
@@ -76,10 +109,7 @@ public boolean equals(Object obj) {
76109
if (!Objects.equals(this.internalId, other.internalId)) {
77110
return false;
78111
}
79-
if (!Objects.equals(this.generationTime, other.generationTime)) {
80-
return false;
81-
}
82-
return true;
112+
return Objects.equals(this.generationTime, other.generationTime);
83113
}
84114

85115
@Override

eu.dariolucia.reatmetric.api/src/main/java/eu/dariolucia/reatmetric/api/common/AbstractDataItemFilter.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
package eu.dariolucia.reatmetric.api.common;
1717

1818
import eu.dariolucia.reatmetric.api.model.SystemEntity;
19-
import eu.dariolucia.reatmetric.api.model.SystemEntityPath;
20-
import eu.dariolucia.reatmetric.api.model.SystemEntityType;
2119

2220
import java.io.Serializable;
2321
import java.util.function.Predicate;

eu.dariolucia.reatmetric.api/src/main/java/eu/dariolucia/reatmetric/api/common/Pair.java

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,26 @@
1919
import java.io.Serializable;
2020
import java.util.Objects;
2121

22+
/**
23+
* A pair class that contains two related values in a single object.
24+
*
25+
* Objects of this class are immutable. Values shall be immutable: failing to have immutable objects as values
26+
* may result in undefined behaviour.
27+
*
28+
* @param <T> type of the first value
29+
* @param <K> type of the second value
30+
*/
2231
public final class Pair<T, K> implements Serializable {
2332

33+
/**
34+
* Factory method.
35+
*
36+
* @param first the first value, can be null
37+
* @param second the second value, can be null
38+
* @param <T> the first value type
39+
* @param <K> the second value type
40+
* @return the Pair object
41+
*/
2442
public static <T,K> Pair<T, K> of(T first, K second) {
2543
return new Pair<>(first, second);
2644
}
@@ -33,14 +51,30 @@ private Pair(T first, K second) {
3351
this.second = second;
3452
}
3553

54+
/**
55+
* Return the first value.
56+
*
57+
* @return the first value (can be null)
58+
*/
3659
public T getFirst() {
3760
return first;
3861
}
3962

63+
/**
64+
* Return the second value.
65+
*
66+
* @return the second value (can be null)
67+
*/
4068
public K getSecond() {
4169
return second;
4270
}
4371

72+
/**
73+
* A Pair is equal to another one if the first values are equals(...) and the second values are equals(...)
74+
*
75+
* @param o the Pair object, to check equality against
76+
* @return true if the pairs are equals, otherwise false
77+
*/
4478
@Override
4579
public boolean equals(Object o) {
4680
if (this == o) return true;

eu.dariolucia.reatmetric.api/src/main/java/eu/dariolucia/reatmetric/api/common/exceptions/ReatmetricException.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,14 @@
1616
package eu.dariolucia.reatmetric.api.common.exceptions;
1717

1818
/**
19-
*
20-
* @author dario
19+
* Base-class for ReatMetric-defined exceptions.
2120
*/
2221
public class ReatmetricException extends Exception {
2322

2423
/**
2524
*
2625
*/
27-
private static final long serialVersionUID = -3949315104317147362L;
26+
private static final long serialVersionUID = 1L;
2827

2928
public ReatmetricException() {
3029
}

0 commit comments

Comments
 (0)