SdkComponents { public String registerCoder(Coder<?> coder) throws IOException { String existing = coderIds.get(coder); if (existing != null) { return existing; } String baseName = NameUtils.approximateSimpleName(coder); String name = uniqify(baseName, coderIds.values()); coderIds.put(coder, name); RunnerApi.Coder coderProto = CoderTranslation.toProto(coder, this); componentsBuilder.putCoders(name, coderProto); return name; } private  SdkComponents(
      @Nullable Components components,
      @Nullable Collection<String> requirements,
      String newIdPrefix); static SdkComponents create(); static SdkComponents create(
      RunnerApi.Components components, Collection<String> requirements); static SdkComponents create(PipelineOptions options); void mergeFrom(
      RunnerApi.Components components, @Nullable Collection<String> requirements); SdkComponents withNewIdPrefix(String newIdPrefix); String registerPTransform(
      AppliedPTransform<?, ?, ?> appliedPTransform, List<AppliedPTransform<?, ?, ?>> children); String getPTransformIdOrThrow(AppliedPTransform<?, ?, ?> appliedPTransform); String registerPCollection(PCollection<?> pCollection); String registerWindowingStrategy(WindowingStrategy<?, ?> windowingStrategy); String registerCoder(Coder<?> coder); String registerEnvironment(Environment env); String getOnlyEnvironmentId(); void addRequirement(String urn); RunnerApi.Components toComponents(); Collection<String> requirements();  }
@Test public void registerCoder() throws IOException { Coder<?> coder = KvCoder.of(StringUtf8Coder.of(), IterableCoder.of(SetCoder.of(ByteArrayCoder.of()))); String id = components.registerCoder(coder); assertThat(components.registerCoder(coder), equalTo(id)); assertThat(id, not(isEmptyOrNullString())); Coder<?> equalCoder = KvCoder.of(StringUtf8Coder.of(), IterableCoder.of(SetCoder.of(ByteArrayCoder.of()))); assertThat(components.registerCoder(equalCoder), equalTo(id)); Coder<?> otherCoder = VarLongCoder.of(); assertThat(components.registerCoder(otherCoder), not(equalTo(id))); components.toComponents().getCodersOrThrow(id); components.toComponents().getCodersOrThrow(components.registerCoder(otherCoder)); }