Class Bundle.Builder

java.lang.Object
security.whisper.javastix.bundle.Bundle.Builder
Enclosing class:
Bundle

@NotThreadSafe public static final class Bundle.Builder extends Object
Builds instances of type Bundle. Initialize attributes and then invoke the build() method to create an immutable instance.

Builder is not thread-safe and generally should not be stored in a field or collection, but instead used immediately to create instances.

  • Method Details

    • from

      @CanIgnoreReturnValue public final Bundle.Builder from(BundleObject instance)
      Fill a builder with attribute values from the provided security.whisper.javastix.bundle.BundleObject instance.
      Parameters:
      instance - The instance from which to copy values
      Returns:
      this builder for use in a chained invocation
    • from

      @CanIgnoreReturnValue public final Bundle.Builder from(StixCustomProperties instance)
      Fill a builder with attribute values from the provided security.whisper.javastix.common.StixCustomProperties instance.
      Parameters:
      instance - The instance from which to copy values
      Returns:
      this builder for use in a chained invocation
    • type

      @CanIgnoreReturnValue @JsonPropertyDescription("The type property identifies the type of STIX Object (SDO, Relationship Object, etc). The value of the type field MUST be one of the types defined by a STIX Object (e.g., indicator).") public final Bundle.Builder type(String type)
      Initializes the value for the type attribute.
      Parameters:
      type - The value for type (can be null)
      Returns:
      this builder for use in a chained invocation
    • id

      @CanIgnoreReturnValue @JsonPropertyDescription("Represents identifiers across the CTI specifications. The format consists of the name of the top-level object being identified, followed by two dashes (--), followed by a UUIDv4.") public final Bundle.Builder id(String id)
      Initializes the value for the id attribute.
      Parameters:
      id - The value for id (can be null)
      Returns:
      this builder for use in a chained invocation
    • specVersion

      @CanIgnoreReturnValue @JsonPropertyDescription("The version of the STIX specification used to represent the content in this bundle.") public final Bundle.Builder specVersion(String specVersion)
      Initializes the value for the specVersion attribute.

      If not set, this attribute will have a default value as returned by the initializer of specVersion.

      Parameters:
      specVersion - The value for specVersion
      Returns:
      this builder for use in a chained invocation
    • addObject

      @CanIgnoreReturnValue public final Bundle.Builder addObject(@Nullable BundleableObject element)
      Adds one element to objects set.
      Parameters:
      element - A objects element
      Returns:
      this builder for use in a chained invocation
    • addObjects

      @CanIgnoreReturnValue public final Bundle.Builder addObjects(BundleableObject... elements)
      Adds elements to objects set.
      Parameters:
      elements - An array of objects elements
      Returns:
      this builder for use in a chained invocation
    • objects

      @CanIgnoreReturnValue @JsonPropertyDescription("Specifies a set of one or more STIX Objects.") public final Bundle.Builder objects(Iterable<? extends BundleableObject> elements)
      Sets or replaces all elements for objects set.
      Parameters:
      elements - An iterable of objects elements
      Returns:
      this builder for use in a chained invocation
    • addAllObjects

      @CanIgnoreReturnValue public final Bundle.Builder addAllObjects(Iterable<? extends BundleableObject> elements)
      Adds elements to objects set.
      Parameters:
      elements - An iterable of objects elements
      Returns:
      this builder for use in a chained invocation
    • putCustomProperty

      @CanIgnoreReturnValue public final Bundle.Builder putCustomProperty(String key, Object value)
      Put one entry to the customProperties map.
      Parameters:
      key - The key in the customProperties map
      value - The associated value in the customProperties map
      Returns:
      this builder for use in a chained invocation
    • putCustomProperty

      @CanIgnoreReturnValue public final Bundle.Builder putCustomProperty(Map.Entry<String,? extends Object> entry)
      Put one entry to the customProperties map. Nulls are not permitted
      Parameters:
      entry - The key and value entry
      Returns:
      this builder for use in a chained invocation
    • customProperties

      @CanIgnoreReturnValue public final Bundle.Builder customProperties(Map<String,? extends Object> entries)
      Sets or replaces all mappings from the specified map as entries for the customProperties map. Nulls are not permitted
      Parameters:
      entries - The entries that will be added to the customProperties map
      Returns:
      this builder for use in a chained invocation
    • putAllCustomProperties

      @CanIgnoreReturnValue public final Bundle.Builder putAllCustomProperties(Map<String,? extends Object> entries)
      Put all mappings from the specified map as entries to customProperties map. Nulls are not permitted
      Parameters:
      entries - The entries that will be added to the customProperties map
      Returns:
      this builder for use in a chained invocation
    • build

      public Bundle build()
      Builds a new Bundle.
      Returns:
      An immutable instance of BundleObject
      Throws:
      IllegalStateException - if any required attributes are missing