Class Duration.Builder

  • All Implemented Interfaces:
    com.google.protobuf.Message.Builder, com.google.protobuf.MessageLite.Builder, com.google.protobuf.MessageLiteOrBuilder, com.google.protobuf.MessageOrBuilder, java.lang.Cloneable, DurationOrBuilder
    Enclosing class:
    Duration

    public static final class Duration.Builder
    extends com.google.protobuf.GeneratedMessageV3.Builder<Duration.Builder>
    implements DurationOrBuilder
     A Duration represents a signed, fixed-length span of time represented
     as a count of seconds and fractions of seconds at nanosecond
     resolution. It is independent of any calendar and concepts like "day"
     or "month". It is related to Timestamp in that the difference between
     two Timestamp values is a Duration and it can be added or subtracted
     from a Timestamp. Range is approximately +-10,000 years.
     # Examples
     Example 1: Compute Duration from two Timestamps in pseudo code.
         Timestamp start = ...;
         Timestamp end = ...;
         Duration duration = ...;
         duration.seconds = end.seconds - start.seconds;
         duration.nanos = end.nanos - start.nanos;
         if (duration.seconds < 0 && duration.nanos > 0) {
           duration.seconds += 1;
           duration.nanos -= 1000000000;
         } else if (durations.seconds > 0 && duration.nanos < 0) {
           duration.seconds -= 1;
           duration.nanos += 1000000000;
         }
     Example 2: Compute Timestamp from Timestamp + Duration in pseudo code.
         Timestamp start = ...;
         Duration duration = ...;
         Timestamp end = ...;
         end.seconds = start.seconds + duration.seconds;
         end.nanos = start.nanos + duration.nanos;
         if (end.nanos < 0) {
           end.seconds -= 1;
           end.nanos += 1000000000;
         } else if (end.nanos >= 1000000000) {
           end.seconds += 1;
           end.nanos -= 1000000000;
         }
     Example 3: Compute Duration from datetime.timedelta in Python.
         td = datetime.timedelta(days=3, minutes=10)
         duration = Duration()
         duration.FromTimedelta(td)
     # JSON Mapping
     In JSON format, the Duration type is encoded as a string rather than an
     object, where the string ends in the suffix "s" (indicating seconds) and
     is preceded by the number of seconds, with nanoseconds expressed as
     fractional seconds. For example, 3 seconds with 0 nanoseconds should be
     encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should
     be expressed in JSON format as "3.000000001s", and 3 seconds and 1
     microsecond should be expressed in JSON format as "3.000001s".
     
    Protobuf type org.platanios.tensorflow.proto.Duration
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Duration.Builder addRepeatedField​(com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value)  
      Duration build()  
      Duration buildPartial()  
      Duration.Builder clear()  
      Duration.Builder clearField​(com.google.protobuf.Descriptors.FieldDescriptor field)  
      Duration.Builder clearNanos()
      Signed fractions of a second at nanosecond resolution of the span of time.
      Duration.Builder clearOneof​(com.google.protobuf.Descriptors.OneofDescriptor oneof)  
      Duration.Builder clearSeconds()
      Signed seconds of the span of time.
      Duration.Builder clone()  
      Duration getDefaultInstanceForType()  
      static com.google.protobuf.Descriptors.Descriptor getDescriptor()  
      com.google.protobuf.Descriptors.Descriptor getDescriptorForType()  
      int getNanos()
      Signed fractions of a second at nanosecond resolution of the span of time.
      long getSeconds()
      Signed seconds of the span of time.
      protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable()  
      boolean isInitialized()  
      Duration.Builder mergeFrom​(com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry)  
      Duration.Builder mergeFrom​(com.google.protobuf.Message other)  
      Duration.Builder mergeFrom​(Duration other)  
      Duration.Builder mergeUnknownFields​(com.google.protobuf.UnknownFieldSet unknownFields)  
      Duration.Builder setField​(com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value)  
      Duration.Builder setNanos​(int value)
      Signed fractions of a second at nanosecond resolution of the span of time.
      Duration.Builder setRepeatedField​(com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value)  
      Duration.Builder setSeconds​(long value)
      Signed seconds of the span of time.
      Duration.Builder setUnknownFields​(com.google.protobuf.UnknownFieldSet unknownFields)  
      • Methods inherited from class com.google.protobuf.GeneratedMessageV3.Builder

        getAllFields, getField, getFieldBuilder, getOneofFieldDescriptor, getParentForChildren, getRepeatedField, getRepeatedFieldBuilder, getRepeatedFieldCount, getUnknownFields, hasField, hasOneof, internalGetMapField, internalGetMutableMapField, isClean, markClean, newBuilderForField, onBuilt, onChanged, setUnknownFieldsProto3
      • Methods inherited from class com.google.protobuf.AbstractMessage.Builder

        findInitializationErrors, getInitializationErrorString, internalMergeFrom, mergeDelimitedFrom, mergeDelimitedFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, newUninitializedMessageException, toString
      • Methods inherited from class com.google.protobuf.AbstractMessageLite.Builder

        addAll, addAll, mergeFrom, newUninitializedMessageException
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface com.google.protobuf.MessageLite.Builder

        mergeFrom
      • Methods inherited from interface com.google.protobuf.MessageOrBuilder

        findInitializationErrors, getAllFields, getField, getInitializationErrorString, getOneofFieldDescriptor, getRepeatedField, getRepeatedFieldCount, getUnknownFields, hasField, hasOneof
    • Method Detail

      • getDescriptor

        public static final com.google.protobuf.Descriptors.Descriptor getDescriptor()
      • internalGetFieldAccessorTable

        protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable()
        Specified by:
        internalGetFieldAccessorTable in class com.google.protobuf.GeneratedMessageV3.Builder<Duration.Builder>
      • clear

        public Duration.Builder clear()
        Specified by:
        clear in interface com.google.protobuf.Message.Builder
        Specified by:
        clear in interface com.google.protobuf.MessageLite.Builder
        Overrides:
        clear in class com.google.protobuf.GeneratedMessageV3.Builder<Duration.Builder>
      • getDescriptorForType

        public com.google.protobuf.Descriptors.Descriptor getDescriptorForType()
        Specified by:
        getDescriptorForType in interface com.google.protobuf.Message.Builder
        Specified by:
        getDescriptorForType in interface com.google.protobuf.MessageOrBuilder
        Overrides:
        getDescriptorForType in class com.google.protobuf.GeneratedMessageV3.Builder<Duration.Builder>
      • getDefaultInstanceForType

        public Duration getDefaultInstanceForType()
        Specified by:
        getDefaultInstanceForType in interface com.google.protobuf.MessageLiteOrBuilder
        Specified by:
        getDefaultInstanceForType in interface com.google.protobuf.MessageOrBuilder
      • build

        public Duration build()
        Specified by:
        build in interface com.google.protobuf.Message.Builder
        Specified by:
        build in interface com.google.protobuf.MessageLite.Builder
      • buildPartial

        public Duration buildPartial()
        Specified by:
        buildPartial in interface com.google.protobuf.Message.Builder
        Specified by:
        buildPartial in interface com.google.protobuf.MessageLite.Builder
      • clone

        public Duration.Builder clone()
        Specified by:
        clone in interface com.google.protobuf.Message.Builder
        Specified by:
        clone in interface com.google.protobuf.MessageLite.Builder
        Overrides:
        clone in class com.google.protobuf.GeneratedMessageV3.Builder<Duration.Builder>
      • setField

        public Duration.Builder setField​(com.google.protobuf.Descriptors.FieldDescriptor field,
                                         java.lang.Object value)
        Specified by:
        setField in interface com.google.protobuf.Message.Builder
        Overrides:
        setField in class com.google.protobuf.GeneratedMessageV3.Builder<Duration.Builder>
      • clearField

        public Duration.Builder clearField​(com.google.protobuf.Descriptors.FieldDescriptor field)
        Specified by:
        clearField in interface com.google.protobuf.Message.Builder
        Overrides:
        clearField in class com.google.protobuf.GeneratedMessageV3.Builder<Duration.Builder>
      • clearOneof

        public Duration.Builder clearOneof​(com.google.protobuf.Descriptors.OneofDescriptor oneof)
        Specified by:
        clearOneof in interface com.google.protobuf.Message.Builder
        Overrides:
        clearOneof in class com.google.protobuf.GeneratedMessageV3.Builder<Duration.Builder>
      • setRepeatedField

        public Duration.Builder setRepeatedField​(com.google.protobuf.Descriptors.FieldDescriptor field,
                                                 int index,
                                                 java.lang.Object value)
        Specified by:
        setRepeatedField in interface com.google.protobuf.Message.Builder
        Overrides:
        setRepeatedField in class com.google.protobuf.GeneratedMessageV3.Builder<Duration.Builder>
      • addRepeatedField

        public Duration.Builder addRepeatedField​(com.google.protobuf.Descriptors.FieldDescriptor field,
                                                 java.lang.Object value)
        Specified by:
        addRepeatedField in interface com.google.protobuf.Message.Builder
        Overrides:
        addRepeatedField in class com.google.protobuf.GeneratedMessageV3.Builder<Duration.Builder>
      • mergeFrom

        public Duration.Builder mergeFrom​(com.google.protobuf.Message other)
        Specified by:
        mergeFrom in interface com.google.protobuf.Message.Builder
        Overrides:
        mergeFrom in class com.google.protobuf.AbstractMessage.Builder<Duration.Builder>
      • isInitialized

        public final boolean isInitialized()
        Specified by:
        isInitialized in interface com.google.protobuf.MessageLiteOrBuilder
        Overrides:
        isInitialized in class com.google.protobuf.GeneratedMessageV3.Builder<Duration.Builder>
      • mergeFrom

        public Duration.Builder mergeFrom​(com.google.protobuf.CodedInputStream input,
                                          com.google.protobuf.ExtensionRegistryLite extensionRegistry)
                                   throws java.io.IOException
        Specified by:
        mergeFrom in interface com.google.protobuf.Message.Builder
        Specified by:
        mergeFrom in interface com.google.protobuf.MessageLite.Builder
        Overrides:
        mergeFrom in class com.google.protobuf.AbstractMessage.Builder<Duration.Builder>
        Throws:
        java.io.IOException
      • getSeconds

        public long getSeconds()
         Signed seconds of the span of time. Must be from -315,576,000,000
         to +315,576,000,000 inclusive. Note: these bounds are computed from:
         60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years
         
        int64 seconds = 1;
        Specified by:
        getSeconds in interface DurationOrBuilder
        Returns:
        The seconds.
      • setSeconds

        public Duration.Builder setSeconds​(long value)
         Signed seconds of the span of time. Must be from -315,576,000,000
         to +315,576,000,000 inclusive. Note: these bounds are computed from:
         60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years
         
        int64 seconds = 1;
        Parameters:
        value - The seconds to set.
        Returns:
        This builder for chaining.
      • clearSeconds

        public Duration.Builder clearSeconds()
         Signed seconds of the span of time. Must be from -315,576,000,000
         to +315,576,000,000 inclusive. Note: these bounds are computed from:
         60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years
         
        int64 seconds = 1;
        Returns:
        This builder for chaining.
      • getNanos

        public int getNanos()
         Signed fractions of a second at nanosecond resolution of the span
         of time. Durations less than one second are represented with a 0
         `seconds` field and a positive or negative `nanos` field. For durations
         of one second or more, a non-zero value for the `nanos` field must be
         of the same sign as the `seconds` field. Must be from -999,999,999
         to +999,999,999 inclusive.
         
        int32 nanos = 2;
        Specified by:
        getNanos in interface DurationOrBuilder
        Returns:
        The nanos.
      • setNanos

        public Duration.Builder setNanos​(int value)
         Signed fractions of a second at nanosecond resolution of the span
         of time. Durations less than one second are represented with a 0
         `seconds` field and a positive or negative `nanos` field. For durations
         of one second or more, a non-zero value for the `nanos` field must be
         of the same sign as the `seconds` field. Must be from -999,999,999
         to +999,999,999 inclusive.
         
        int32 nanos = 2;
        Parameters:
        value - The nanos to set.
        Returns:
        This builder for chaining.
      • clearNanos

        public Duration.Builder clearNanos()
         Signed fractions of a second at nanosecond resolution of the span
         of time. Durations less than one second are represented with a 0
         `seconds` field and a positive or negative `nanos` field. For durations
         of one second or more, a non-zero value for the `nanos` field must be
         of the same sign as the `seconds` field. Must be from -999,999,999
         to +999,999,999 inclusive.
         
        int32 nanos = 2;
        Returns:
        This builder for chaining.
      • setUnknownFields

        public final Duration.Builder setUnknownFields​(com.google.protobuf.UnknownFieldSet unknownFields)
        Specified by:
        setUnknownFields in interface com.google.protobuf.Message.Builder
        Overrides:
        setUnknownFields in class com.google.protobuf.GeneratedMessageV3.Builder<Duration.Builder>
      • mergeUnknownFields

        public final Duration.Builder mergeUnknownFields​(com.google.protobuf.UnknownFieldSet unknownFields)
        Specified by:
        mergeUnknownFields in interface com.google.protobuf.Message.Builder
        Overrides:
        mergeUnknownFields in class com.google.protobuf.GeneratedMessageV3.Builder<Duration.Builder>