@Override public String toString() { return name() + "[" + pattern + "]"; }
public static String parseConjurePackage(com.palantir.conjure.parser.types.names.ConjurePackage parsed) { return parsed.name(); }
@Override public ForeignReferenceType parse(ParserState input) throws ParseException { String namespace = NAMESPACE_PARSER.parse(input); if (Parsers.nullOrUnexpected(Parsers.expect(".").parse(input))) { return null; } String ref = TypeReferenceParser.REF_PARSER.parse(input); ConjureMetrics.incrementCounter(ForeignReferenceType.class); return ForeignReferenceType.of(Namespace.of(namespace), TypeName.of(ref)); } }
public static ConjurePackage of(Iterable<String> components) { return of(Joiner.on('.').join(components)); } }
/** * Converts this {@link FieldName} to an upper camel case string (e.g. myVariant -> MyVariant). * Note that the resultant string is no longer a valid {@link FieldName}. */ public final String capitalize() { return StringUtils.capitalize(name()); } }
@Auxiliary public final com.palantir.conjure.spec.ErrorCode asSpecErrorCode() { return com.palantir.conjure.spec.ErrorCode.valueOf(name()); }
@Override String convertTo(FieldName fieldName, Case targetCase) { switch (targetCase) { case LOWER_CAMEL_CASE: return CaseFormat.LOWER_HYPHEN.to(CaseFormat.LOWER_CAMEL, fieldName.name()); case KEBAB_CASE: return fieldName.name(); case SNAKE_CASE: return CaseFormat.LOWER_HYPHEN.to(CaseFormat.LOWER_UNDERSCORE, fieldName.name()); } throw new IllegalArgumentException("Unknown FieldName case, this is a bug: " + targetCase); } },
/** Returns the components of the package, i.e. return {@code {abc, efg}} for package {@code abc.efg}. */ @Value.Lazy public List<String> components() { return ImmutableList.copyOf(Splitter.on('.').split(name())); }
@Override String convertTo(FieldName fieldName, Case targetCase) { switch (targetCase) { case LOWER_CAMEL_CASE: return fieldName.name(); case KEBAB_CASE: return CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_HYPHEN, fieldName.name()); case SNAKE_CASE: return CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, fieldName.name()); } throw new IllegalArgumentException("Unknown FieldName case, this is a bug: " + targetCase); } },
@Override String convertTo(FieldName fieldName, Case targetCase) { switch (targetCase) { case LOWER_CAMEL_CASE: return CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, fieldName.name()); case KEBAB_CASE: return CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_HYPHEN, fieldName.name()); case SNAKE_CASE: return fieldName.name(); } throw new IllegalArgumentException("Unknown FieldName case, this is a bug: " + targetCase); } };
private static FieldName parseFieldName(com.palantir.conjure.parser.types.names.FieldName parserFieldName) { FieldName fieldName = FieldName.of(parserFieldName.name()); FieldNameValidator.validate(fieldName); return fieldName; }