Class DiagnosisKeyBuilder

  • All Implemented Interfaces:
    app.coronawarn.server.common.persistence.domain.DiagnosisKeyBuilders.Builder, app.coronawarn.server.common.persistence.domain.DiagnosisKeyBuilders.FinalBuilder, app.coronawarn.server.common.persistence.domain.DiagnosisKeyBuilders.RollingStartIntervalNumberBuilder, app.coronawarn.server.common.persistence.domain.DiagnosisKeyBuilders.TransmissionRiskLevelBuilder

    public class DiagnosisKeyBuilder
    extends Object
    implements app.coronawarn.server.common.persistence.domain.DiagnosisKeyBuilders.Builder, app.coronawarn.server.common.persistence.domain.DiagnosisKeyBuilders.RollingStartIntervalNumberBuilder, app.coronawarn.server.common.persistence.domain.DiagnosisKeyBuilders.TransmissionRiskLevelBuilder, app.coronawarn.server.common.persistence.domain.DiagnosisKeyBuilders.FinalBuilder
    An instance of this builder can be retrieved by calling DiagnosisKey.builder(). A DiagnosisKey can then be build by either providing the required member values or by passing the respective protocol buffer object.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      DiagnosisKey build()
      Builds a DiagnosisKey instance.
      app.coronawarn.server.common.persistence.domain.DiagnosisKeyBuilders.FinalBuilder fromFederationDiagnosisKey​(DiagnosisKey federationDiagnosisKey)
      Adds the data contained in the specified federation diagnosis key object to this builder.
      app.coronawarn.server.common.persistence.domain.DiagnosisKeyBuilders.FinalBuilder fromTemporaryExposureKeyAndMetadata​(TemporaryExposureKey protoBufObject, List<String> visitedCountries, String originCountry, boolean consentToFederation)
      Adds the data contained in the specified protocol buffers key object and metadata to this builder.
      app.coronawarn.server.common.persistence.domain.DiagnosisKeyBuilders.FinalBuilder withConsentToFederation​(boolean consentToFederation)  
      app.coronawarn.server.common.persistence.domain.DiagnosisKeyBuilders.FinalBuilder withCountryCode​(String countryCode)  
      app.coronawarn.server.common.persistence.domain.DiagnosisKeyBuilders.FinalBuilder withDaysSinceOnsetOfSymptoms​(Integer daysSinceOnsetOfSymptoms)  
      app.coronawarn.server.common.persistence.domain.DiagnosisKeyBuilders.FinalBuilder withFieldNormalization​(DiagnosisKeyNormalizer fieldNormalizer)
      Field normalization is applied after all values have been provided, but prior to construction of the DiagnosisKey.
      app.coronawarn.server.common.persistence.domain.DiagnosisKeyBuilders.RollingStartIntervalNumberBuilder withKeyData​(byte[] keyData)
      Adds the specified key data to this builder.
      app.coronawarn.server.common.persistence.domain.DiagnosisKeyBuilders.FinalBuilder withReportType​(ReportType reportType)  
      app.coronawarn.server.common.persistence.domain.DiagnosisKeyBuilders.FinalBuilder withRollingPeriod​(int rollingPeriod)
      Adds the specified rolling period to this builder.
      app.coronawarn.server.common.persistence.domain.DiagnosisKeyBuilders.TransmissionRiskLevelBuilder withRollingStartIntervalNumber​(int rollingStartIntervalNumber)
      Adds the specified rolling start interval number to this builder.
      app.coronawarn.server.common.persistence.domain.DiagnosisKeyBuilders.FinalBuilder withSubmissionTimestamp​(long submissionTimestamp)
      Adds the specified submission timestamp that is expected to represent hours since epoch.
      app.coronawarn.server.common.persistence.domain.DiagnosisKeyBuilders.FinalBuilder withTransmissionRiskLevel​(Integer transmissionRiskLevel)
      Adds the specified transmission risk level to this builder.
      app.coronawarn.server.common.persistence.domain.DiagnosisKeyBuilders.FinalBuilder withVisitedCountries​(Set<String> visitedCountries)  
    • Method Detail

      • withKeyData

        public app.coronawarn.server.common.persistence.domain.DiagnosisKeyBuilders.RollingStartIntervalNumberBuilder withKeyData​(byte[] keyData)
        Description copied from interface: app.coronawarn.server.common.persistence.domain.DiagnosisKeyBuilders.Builder
        Adds the specified key data to this builder.
        Specified by:
        withKeyData in interface app.coronawarn.server.common.persistence.domain.DiagnosisKeyBuilders.Builder
        Parameters:
        keyData - generated diagnosis key.
        Returns:
        this Builder instance.
      • withRollingStartIntervalNumber

        public app.coronawarn.server.common.persistence.domain.DiagnosisKeyBuilders.TransmissionRiskLevelBuilder withRollingStartIntervalNumber​(int rollingStartIntervalNumber)
        Description copied from interface: app.coronawarn.server.common.persistence.domain.DiagnosisKeyBuilders.RollingStartIntervalNumberBuilder
        Adds the specified rolling start interval number to this builder.
        Specified by:
        withRollingStartIntervalNumber in interface app.coronawarn.server.common.persistence.domain.DiagnosisKeyBuilders.RollingStartIntervalNumberBuilder
        Parameters:
        rollingStartIntervalNumber - number describing when a key starts. It is equal to startTimeOfKeySinceEpochInSecs / (60 * 10).
        Returns:
        this Builder instance.
      • withTransmissionRiskLevel

        public app.coronawarn.server.common.persistence.domain.DiagnosisKeyBuilders.FinalBuilder withTransmissionRiskLevel​(Integer transmissionRiskLevel)
        Description copied from interface: app.coronawarn.server.common.persistence.domain.DiagnosisKeyBuilders.TransmissionRiskLevelBuilder
        Adds the specified transmission risk level to this builder.
        Specified by:
        withTransmissionRiskLevel in interface app.coronawarn.server.common.persistence.domain.DiagnosisKeyBuilders.TransmissionRiskLevelBuilder
        Parameters:
        transmissionRiskLevel - risk of transmission associated with the person this key came from.
        Returns:
        this Builder instance.
      • fromTemporaryExposureKeyAndMetadata

        public app.coronawarn.server.common.persistence.domain.DiagnosisKeyBuilders.FinalBuilder fromTemporaryExposureKeyAndMetadata​(TemporaryExposureKey protoBufObject,
                                                                                                                                     List<String> visitedCountries,
                                                                                                                                     String originCountry,
                                                                                                                                     boolean consentToFederation)
        Description copied from interface: app.coronawarn.server.common.persistence.domain.DiagnosisKeyBuilders.Builder
        Adds the data contained in the specified protocol buffers key object and metadata to this builder.
        Specified by:
        fromTemporaryExposureKeyAndMetadata in interface app.coronawarn.server.common.persistence.domain.DiagnosisKeyBuilders.Builder
        Parameters:
        protoBufObject - ProtocolBuffer object associated with the temporary exposure key.
        visitedCountries - The list of visited countries to add to the diagnosis key.
        originCountry - The origin country to set in the diagnosis key.
        consentToFederation - Indicates if the user has given his consent to share this diagnosis key via federation.
        Returns:
        this Builder instance.
      • fromFederationDiagnosisKey

        public app.coronawarn.server.common.persistence.domain.DiagnosisKeyBuilders.FinalBuilder fromFederationDiagnosisKey​(DiagnosisKey federationDiagnosisKey)
        Description copied from interface: app.coronawarn.server.common.persistence.domain.DiagnosisKeyBuilders.Builder
        Adds the data contained in the specified federation diagnosis key object to this builder.
        Specified by:
        fromFederationDiagnosisKey in interface app.coronawarn.server.common.persistence.domain.DiagnosisKeyBuilders.Builder
        Parameters:
        federationDiagnosisKey - DiagnosisKey object associated with the temporary exposure key.
        Returns:
        this Builder instance.
      • withSubmissionTimestamp

        public app.coronawarn.server.common.persistence.domain.DiagnosisKeyBuilders.FinalBuilder withSubmissionTimestamp​(long submissionTimestamp)
        Description copied from interface: app.coronawarn.server.common.persistence.domain.DiagnosisKeyBuilders.FinalBuilder
        Adds the specified submission timestamp that is expected to represent hours since epoch.
        Specified by:
        withSubmissionTimestamp in interface app.coronawarn.server.common.persistence.domain.DiagnosisKeyBuilders.FinalBuilder
        Parameters:
        submissionTimestamp - timestamp in hours since epoch.
        Returns:
        this Builder instance.
      • withRollingPeriod

        public app.coronawarn.server.common.persistence.domain.DiagnosisKeyBuilders.FinalBuilder withRollingPeriod​(int rollingPeriod)
        Description copied from interface: app.coronawarn.server.common.persistence.domain.DiagnosisKeyBuilders.FinalBuilder
        Adds the specified rolling period to this builder. If not specified, the rolling period defaults to DiagnosisKey.MAX_ROLLING_PERIOD
        Specified by:
        withRollingPeriod in interface app.coronawarn.server.common.persistence.domain.DiagnosisKeyBuilders.FinalBuilder
        Parameters:
        rollingPeriod - Number describing how long a key is valid. It is expressed in increments of 10 minutes (e.g. 144 for 24 hours).
        Returns:
        this Builder instance.
      • withConsentToFederation

        public app.coronawarn.server.common.persistence.domain.DiagnosisKeyBuilders.FinalBuilder withConsentToFederation​(boolean consentToFederation)
        Specified by:
        withConsentToFederation in interface app.coronawarn.server.common.persistence.domain.DiagnosisKeyBuilders.FinalBuilder
      • withCountryCode

        public app.coronawarn.server.common.persistence.domain.DiagnosisKeyBuilders.FinalBuilder withCountryCode​(String countryCode)
        Specified by:
        withCountryCode in interface app.coronawarn.server.common.persistence.domain.DiagnosisKeyBuilders.FinalBuilder
      • withVisitedCountries

        public app.coronawarn.server.common.persistence.domain.DiagnosisKeyBuilders.FinalBuilder withVisitedCountries​(Set<String> visitedCountries)
        Specified by:
        withVisitedCountries in interface app.coronawarn.server.common.persistence.domain.DiagnosisKeyBuilders.FinalBuilder
      • withReportType

        public app.coronawarn.server.common.persistence.domain.DiagnosisKeyBuilders.FinalBuilder withReportType​(ReportType reportType)
        Specified by:
        withReportType in interface app.coronawarn.server.common.persistence.domain.DiagnosisKeyBuilders.FinalBuilder
      • withDaysSinceOnsetOfSymptoms

        public app.coronawarn.server.common.persistence.domain.DiagnosisKeyBuilders.FinalBuilder withDaysSinceOnsetOfSymptoms​(Integer daysSinceOnsetOfSymptoms)
        Specified by:
        withDaysSinceOnsetOfSymptoms in interface app.coronawarn.server.common.persistence.domain.DiagnosisKeyBuilders.FinalBuilder
      • withFieldNormalization

        public app.coronawarn.server.common.persistence.domain.DiagnosisKeyBuilders.FinalBuilder withFieldNormalization​(DiagnosisKeyNormalizer fieldNormalizer)
        Description copied from interface: app.coronawarn.server.common.persistence.domain.DiagnosisKeyBuilders.FinalBuilder
        Field normalization is applied after all values have been provided, but prior to construction of the DiagnosisKey. For flexibility purpose, providing a normalizer object is optional.
        Specified by:
        withFieldNormalization in interface app.coronawarn.server.common.persistence.domain.DiagnosisKeyBuilders.FinalBuilder
      • build

        public DiagnosisKey build()
        Description copied from interface: app.coronawarn.server.common.persistence.domain.DiagnosisKeyBuilders.FinalBuilder
        Builds a DiagnosisKey instance. If no submission timestamp has been specified it will be set to "now" as hours since epoch.
        Specified by:
        build in interface app.coronawarn.server.common.persistence.domain.DiagnosisKeyBuilders.FinalBuilder