Tabnine Logo
UnionDefinition.builder
Code IndexAdd Tabnine to your IDE (free)

How to use
builder
method
in
com.palantir.conjure.spec.UnionDefinition

Best Java code snippets using com.palantir.conjure.spec.UnionDefinition.builder (Showing top 4 results out of 315)

origin: palantir/conjure

public static TypeDefinition parseUnionType(
    TypeName name,
    com.palantir.conjure.parser.types.complex.UnionTypeDefinition def,
    ConjureTypeParserVisitor.ReferenceTypeResolver typeResolver) {
  UnionDefinition unionType = UnionDefinition.builder()
      .typeName(name)
      .union(parseField(def.union(), typeResolver))
      .docs(def.docs().map(Documentation::of))
      .build();
  UnionDefinitionValidator.validateAll(unionType);
  return TypeDefinition.union(unionType);
}
origin: palantir/conjure

@Test
public void testUnionMemberKeyMustNotBeIllegalJavaIdentifier() {
  ImmutableList.of("%foo", "foo@").forEach(key -> {
    FieldDefinition fieldDefinition = FieldDefinition.builder()
        .fieldName(FieldName.of(key))
        .type(Type.primitive(PrimitiveType.STRING))
        .build();
    assertThatThrownBy(() ->
        UnionDefinitionValidator.validateAll(UnionDefinition.builder()
            .union(fieldDefinition)
            .typeName(TypeName.of("string", ""))
            .build()))
        .isInstanceOf(IllegalArgumentException.class)
          .hasMessageStartingWith(
              String.format("Union member key must be a valid Java identifier: %s", key));
  });
}
origin: palantir/conjure

@Test
public void testUnionMemberKeyMustNotBeEmpty() {
  FieldDefinition fieldDefinition = FieldDefinition.builder()
      .fieldName(FieldName.of(""))
      .type(Type.primitive(PrimitiveType.STRING))
      .build();
  assertThatThrownBy(() ->
      UnionDefinitionValidator.validateAll(UnionDefinition.builder()
          .union(fieldDefinition)
          .typeName(TypeName.of("string", ""))
          .build()))
      .isInstanceOf(IllegalArgumentException.class)
      .hasMessageStartingWith("Union member key must not be empty");
}
origin: palantir/conjure

  @Test
  public void testUnionMemberKeyMustNotHaveTrailingUnderscore() {
    FieldDefinition fieldDefinition = FieldDefinition.builder()
        .fieldName(FieldName.of("foo_"))
        .type(Type.primitive(PrimitiveType.STRING))
        .build();
    assertThatThrownBy(() ->
        UnionDefinitionValidator.validateAll(UnionDefinition.builder()
            .union(fieldDefinition)
            .typeName(TypeName.of("string", ""))
            .build()))
      .isInstanceOf(IllegalArgumentException.class)
      .hasMessageStartingWith("Union member key must not end with an underscore: foo_");
  }
}
com.palantir.conjure.specUnionDefinitionbuilder

Popular methods of UnionDefinition

  • getTypeName
  • getUnion

Popular in Java

  • Start an intent from android
  • onCreateOptionsMenu (Activity)
  • setRequestProperty (URLConnection)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • BigDecimal (java.math)
    An immutable arbitrary-precision signed decimal.A value is represented by an arbitrary-precision "un
  • Locale (java.util)
    Locale represents a language/country/variant combination. Locales are used to alter the presentatio
  • SortedSet (java.util)
    SortedSet is a Set which iterates over its elements in a sorted order. The order is determined eithe
  • Executor (java.util.concurrent)
    An object that executes submitted Runnable tasks. This interface provides a way of decoupling task s
  • Options (org.apache.commons.cli)
    Main entry-point into the library. Options represents a collection of Option objects, which describ
  • Logger (org.slf4j)
    The org.slf4j.Logger interface is the main user entry point of SLF4J API. It is expected that loggin
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now