Search in sources :

Example 6 with ObjectDefinition

use of com.palantir.conjure.spec.ObjectDefinition in project conjure by palantir.

the class DealiasingTypeVisitor method visitReference.

@Override
public Either<TypeDefinition, Type> visitReference(TypeName value) {
    TypeDefinition typeDefinition = objects.get(value);
    Preconditions.checkState(typeDefinition != null, "Referenced TypeDefinition not found in map of types for TypeName: %s", value);
    return typeDefinition.accept(new TypeDefinition.Visitor<Either<TypeDefinition, Type>>() {

        @Override
        public Either<TypeDefinition, Type> visitAlias(AliasDefinition value) {
            // Recursively visit target of alias
            return value.getAlias().accept(DealiasingTypeVisitor.this);
        }

        @Override
        public Either<TypeDefinition, Type> visitEnum(EnumDefinition value) {
            return Either.left(TypeDefinition.enum_(value));
        }

        @Override
        public Either<TypeDefinition, Type> visitObject(ObjectDefinition value) {
            return Either.left(TypeDefinition.object(value));
        }

        @Override
        public Either<TypeDefinition, Type> visitUnion(UnionDefinition value) {
            return Either.left(TypeDefinition.union(value));
        }

        @Override
        public Either<TypeDefinition, Type> visitUnknown(String unknownType) {
            throw new IllegalStateException("Unsupported type: " + unknownType);
        }
    });
}
Also used : AliasDefinition(com.palantir.conjure.spec.AliasDefinition) Either(com.palantir.conjure.either.Either) UnionDefinition(com.palantir.conjure.spec.UnionDefinition) ObjectDefinition(com.palantir.conjure.spec.ObjectDefinition) EnumDefinition(com.palantir.conjure.spec.EnumDefinition) TypeDefinition(com.palantir.conjure.spec.TypeDefinition)

Aggregations

ObjectDefinition (com.palantir.conjure.spec.ObjectDefinition)6 TypeDefinition (com.palantir.conjure.spec.TypeDefinition)4 AliasDefinition (com.palantir.conjure.spec.AliasDefinition)3 EnumDefinition (com.palantir.conjure.spec.EnumDefinition)3 FieldDefinition (com.palantir.conjure.spec.FieldDefinition)3 UnionDefinition (com.palantir.conjure.spec.UnionDefinition)3 FieldName (com.palantir.conjure.spec.FieldName)2 ListType (com.palantir.conjure.spec.ListType)2 MapType (com.palantir.conjure.spec.MapType)2 OptionalType (com.palantir.conjure.spec.OptionalType)2 PrimitiveType (com.palantir.conjure.spec.PrimitiveType)2 SetType (com.palantir.conjure.spec.SetType)2 Type (com.palantir.conjure.spec.Type)2 TypeName (com.palantir.conjure.spec.TypeName)2 List (java.util.List)2 Map (java.util.Map)2 Collectors (java.util.stream.Collectors)2 JsonIgnoreProperties (com.fasterxml.jackson.annotation.JsonIgnoreProperties)1 JsonInclude (com.fasterxml.jackson.annotation.JsonInclude)1 JsonProperty (com.fasterxml.jackson.annotation.JsonProperty)1