Tabnine Logo
FieldDefinition$Builder.fieldName
Code IndexAdd Tabnine to your IDE (free)

How to use
fieldName
method
in
com.palantir.conjure.spec.FieldDefinition$Builder

Best Java code snippets using com.palantir.conjure.spec.FieldDefinition$Builder.fieldName (Showing top 6 results out of 315)

origin: palantir/conjure

static List<FieldDefinition> parseField(
    Map<com.palantir.conjure.parser.types.names.FieldName,
        com.palantir.conjure.parser.types.complex.FieldDefinition> def,
    ConjureTypeParserVisitor.ReferenceTypeResolver typeResolver) {
  return def.entrySet().stream().map(entry -> {
    FieldDefinition fieldDefinition = FieldDefinition.builder()
        .fieldName(parseFieldName(entry.getKey()))
        .type(entry.getValue().type().visit(new ConjureTypeParserVisitor(typeResolver)))
        .docs(entry.getValue().docs().map(Documentation::of)).build();
    FieldDefinitionValidator.validate(fieldDefinition);
    return fieldDefinition;
  }).collect(Collectors.toList());
}
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

  private void testUniqueFieldNameValidator(String fieldName1, String fieldName2) {
    FieldDefinition field1 = FieldDefinition.builder()
        .fieldName(FieldName.of(fieldName1))
        .type(Type.primitive(PrimitiveType.STRING))
        .build();
    FieldDefinition field2 = FieldDefinition.builder()
        .fieldName(FieldName.of(fieldName2))
        .type(Type.primitive(PrimitiveType.STRING))
        .build();
    TypeName name = TypeName.of("Foo", "package");
    ObjectDefinition definition = ObjectDefinition.builder()
        .typeName(name)
        .fields(field1)
        .fields(field2)
        .build();

    assertThatThrownBy(() -> ObjectDefinitionValidator.validate(definition))
        .isInstanceOf(IllegalArgumentException.class)
        .hasMessage(String.format("ObjectDefinition must not contain duplicate field names "
            + "(modulo case normalization): %s vs %s", fieldName2, fieldName1));
  }
}
origin: palantir/conjure

@Test
public void testUniqueArgNamesValidator() {
  FieldDefinition safeArg1 = FieldDefinition.builder()
      .fieldName(FieldName.of("fooBar"))
      .type(Type.primitive(PrimitiveType.STRING))
      .build();
  FieldDefinition unsafeArg1 = FieldDefinition.builder()
      .fieldName(FieldName.of("foo-bar"))
      .type(Type.primitive(PrimitiveType.STRING))
      .build();
      .fieldName(FieldName.of("foo-bar"))
      .type(Type.primitive(PrimitiveType.STRING))
      .build();
  FieldDefinition unsafeArg2 = FieldDefinition.builder()
      .fieldName(FieldName.of("foo_bar"))
      .type(Type.primitive(PrimitiveType.STRING))
      .build();
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_");
  }
}
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");
}
com.palantir.conjure.specFieldDefinition$BuilderfieldName

Popular methods of FieldDefinition$Builder

  • build
  • type
  • docs

Popular in Java

  • Finding current android device location
  • notifyDataSetChanged (ArrayAdapter)
  • setRequestProperty (URLConnection)
  • getSharedPreferences (Context)
  • HttpServer (com.sun.net.httpserver)
    This class implements a simple HTTP server. A HttpServer is bound to an IP address and port number a
  • BufferedImage (java.awt.image)
    The BufferedImage subclass describes an java.awt.Image with an accessible buffer of image data. All
  • Locale (java.util)
    Locale represents a language/country/variant combination. Locales are used to alter the presentatio
  • Set (java.util)
    A Set is a data structure which does not allow duplicate elements.
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
  • Github Copilot 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