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);
}
});
}
Aggregations