@Test void immutableMetadata() throws IOException { Map<String, Object> metadata = new HashMap<>(); metadata.put("key1", "before"); Artifact artifact = Artifact.builder().metadata(metadata).build(); assertThat(artifact.getMetadata("key1")).isEqualTo("before"); assertThat(artifact.getMetadata("key2")).isNull(); metadata.put("key1", "after"); metadata.put("key2", "something"); assertThat(artifact.getMetadata("key1")).isEqualTo("before"); assertThat(artifact.getMetadata("key2")).isNull(); }
@Nullable public Object getMetadata(String key) { return metadata.get(key); }
Artifact { @Nullable public Object getMetadata(String key) { return metadata.get(key); } }
Artifact { @Nullable public Object getMetadata(String key) { return metadata.get(key); } @Builder(toBuilder = true) private  Artifact(
      String type,
      boolean customKind,
      String name,
      String version,
      String location,
      String reference,
      Map<String, Object> metadata,
      String artifactAccount,
      String provenance,
      String uuid); }
Artifact { @Nullable public Object getMetadata(String key) { return metadata.get(key); } @Builder(toBuilder = true) private  Artifact(
      String type,
      boolean customKind,
      String name,
      String version,
      String location,
      String reference,
      Map<String, Object> metadata,
      String artifactAccount,
      String provenance,
      String uuid); @Nullable Object getMetadata(String key); }
Artifact { @Nullable public Object getMetadata(String key) { return metadata.get(key); } @Builder(toBuilder = true) private  Artifact(
      String type,
      boolean customKind,
      String name,
      String version,
      String location,
      String reference,
      Map<String, Object> metadata,
      String artifactAccount,
      String provenance,
      String uuid); @Nullable Object getMetadata(String key);  }