Class ClusterIdentifier
Object
org.anchoranalysis.plugin.io.bean.file.copy.naming.cluster.ClusterIdentifier
public class ClusterIdentifier extends Object
Uniquely identifies a cluster.
We deliberately rely on default Object.hashCode() and Object.equals(Object) so each
instance of the class is unique in a map.
It assumes no two clusters will have the same min and max date-time.
- Author:
- Owen Feehan
-
Constructor Summary
Constructors Constructor Description ClusterIdentifier(String name, ZoneOffset offset)Creates with a constant-name.ClusterIdentifier(ZoneOffset offset)Creates with no name. -
Method Summary
Modifier and Type Method Description voidaddTimestamp(long timestamp)Adds a timestamp to the cluster.voidassignName(String name)Assigns a name for the cluster.longgetMaxInstant()Maximum timestamp in cluster.LocalDateTimegetMaxTime()Gets the latest date-time in the cluster.longgetMinInstant()Minimum timestamp in cluster.LocalDateTimegetMinTime()Gets the earliest date-time in the cluster.ZoneOffsetgetOffset()The offset to assume the time-stamp belongs in.Stringname()Derives a name for the cluster, based upon its contents.
-
Constructor Details
-
ClusterIdentifier
Creates with no name.The name is subsequently derived from the contents of the cluster.
- Parameters:
offset- the offset to assume the time-stamp belongs in.
-
ClusterIdentifier
Creates with a constant-name.- Parameters:
name- the unique name for the cluster.offset- the offset to assume the time-stamp belongs in.
-
-
Method Details
-
addTimestamp
public void addTimestamp(long timestamp)Adds a timestamp to the cluster.- Parameters:
timestamp- the timestamp (seconds since the epoch).
-
assignName
Assigns a name for the cluster.- Parameters:
name- the name to assign.
-
name
Derives a name for the cluster, based upon its contents.- Returns:
- the derived name.
- Throws:
org.anchoranalysis.core.exception.OperationFailedException- ifassignName(String)has not occurred.
-
getMinTime
Gets the earliest date-time in the cluster.This is computed the first time the method is called, and remembered for subsequent calls.
- Returns:
- the minimum date-time in the cluster.
-
getMaxTime
Gets the latest date-time in the cluster.This is computed the first time the method is called, and remembered for subsequent calls.
- Returns:
- the maximum date-time in the cluster.
-
getMinInstant
public long getMinInstant()Minimum timestamp in cluster. This is the earliest time of any file in the cluster. -
getMaxInstant
public long getMaxInstant()Maximum timestamp in cluster. This is the latest time of any file in the cluster. -
getOffset
The offset to assume the time-stamp belongs in.
-