Example usage for java.util Stack Stack

List of usage examples for java.util Stack Stack

Introduction

In this page you can find the example usage for java.util Stack Stack.

Prototype

public Stack() 

Source Link

Document

Creates an empty Stack.

Usage

From source file:com.twitter.common.thrift.text.TTextProtocol.java

/**
 * Create a parser which can read from trans, and create the output writer
 * that can write to a TTransport/*from  w w w  .j a  va  2 s. c  om*/
 */
public TTextProtocol(TTransport trans) {
    super(trans);

    writers = new Stack<WriterByteArrayOutputStream>();

    ByteArrayOutputStream mybaos = new TTransportOutputStream();
    pushWriter(mybaos);

    reset();

    try {
        parser = createParser();
    } catch (IOException ex) {
        // This happens when we're created in write mode (i.e.
        // there is nothing to parse). Calls to read methods will fail.
    }
    contextStack = new Stack<BaseContext>();
    contextStack.push(new BaseContext());
}

From source file:org.openmrs.module.shr.cdahandler.api.impl.CdaImportServiceImpl.java

/**
 * Import the parsed clinical document/*from w  w  w.  j  a va2 s . co  m*/
 * Auto generated method comment
 * 
 * @param clinicalDocument
 * @return
 * @throws DocumentImportException
 */
@Override
public Visit importDocument(ClinicalDocument clinicalDocument) throws DocumentImportException {
    if (this.m_processor == null)
        this.m_processor = CdaImporter.getInstance();

    // TODO: Store incoming to a temporary table for CDAs (like the HL7 queue)
    Visit retVal = this.m_processor.processCdaDocument(clinicalDocument);

    // Notify of successful import
    if (retVal != null) {
        Stack<CdaImportSubscriber> toBeNotified = new Stack<CdaImportSubscriber>();

        // The generic ones for all 
        Set<CdaImportSubscriber> candidates = this.m_subscribers.get("*");
        if (candidates != null)
            for (CdaImportSubscriber subscriber : candidates)
                toBeNotified.push(subscriber);

        // Notify the default always
        for (II templateId : clinicalDocument.getTemplateId()) {
            candidates = this.m_subscribers.get(templateId.getRoot());
            if (candidates == null)
                continue; // no candidates

            for (CdaImportSubscriber subscriber : candidates)
                if (!toBeNotified.contains(subscriber))
                    toBeNotified.push(subscriber);
        }

        // Notify the found subscribers
        while (!toBeNotified.isEmpty())
            toBeNotified.pop().onDocumentImported(clinicalDocument, retVal);
    }

    return retVal;
}

From source file:com.unboundid.scim2.common.utils.SchemaUtils.java

/**
 * Gets schema attributes for the given class.
 * @param cls Class to get the schema attributes for.
 * @return a collection of attributes./*  w  w  w . j  av  a 2  s  .  c o  m*/
 * @throws IntrospectionException thrown if an introspection error occurs.
 */
@Transient
public static Collection<AttributeDefinition> getAttributes(final Class cls) throws IntrospectionException {
    Stack<String> classesProcessed = new Stack<String>();
    return getAttributes(classesProcessed, cls);
}

From source file:com.glaf.core.service.impl.MxQueryDefinitionServiceImpl.java

/**
 * ??,??//  www .j  a  v a  2  s .c o m
 * 
 * @param queryId
 * @return
 */
public Stack<QueryDefinition> getQueryDefinitionStack(String queryId) {
    Stack<QueryDefinition> stack = new Stack<QueryDefinition>();
    QueryDefinition queryDefinition = this.getQueryDefinition(queryId);
    if (queryDefinition != null) {
        stack.push(queryDefinition);
        this.loadQueryDefinitionStack(stack, queryDefinition);
    }
    return stack;
}

From source file:de.uni.bremen.monty.moco.ast.ASTBuilder.java

public ASTBuilder(String fileName, TupleDeclarationFactory tupleDeclarationFactory) {
    this.fileName = fileName;
    currentBlocks = new Stack<>();
    currentGeneratorReturnType = new Stack<>();
    currentGeneratorReturnType.push(null); // initially, we are not inside a generator
    this.tupleDeclarationFactory = tupleDeclarationFactory;
}

From source file:gr.abiss.calipso.wicket.customattrs.CustomAttributeUtils.java

/**
 * Parses the given user intput to create the custom attribute lookup values (options) and their translations, 
 * then add them to the given CustomAttribute.
 * @param optionsTextIput//  w w  w  .j a v  a2s  .  c  o m
 * @param attribute
 * @param languages
 */
public static void parseOptionsIntoAttribute(Map<String, String> optionsTextIput, CustomAttribute attribute,
        List<Language> languages) {
    //logger.info("parseOptionsIntoAttribute, attribute: "+attribute);
    // add options
    attribute.setPersistedVersion(attribute.getVersion());
    attribute.setVersion(attribute.getVersion() + 1);
    attribute.removeAllLookupValues();
    List<CustomAttributeLookupValue> optionsList = new LinkedList<CustomAttributeLookupValue>();
    String languageId = null;
    for (Language language : languages) {
        if (languageId == null) {
            languageId = language.getId();
        }
        String input = optionsTextIput.get(language.getId());
        //logger.info("textAreaOptions.get(language.getId(): "+input);
        if (StringUtils.isNotBlank(input)) {
            Stack<CustomAttributeLookupValue> parents = new Stack<CustomAttributeLookupValue>();
            String[] lines = input.split("\\r?\\n");
            int listIndex = -1;
            for (int j = 0; j < lines.length; j++) {

                listIndex++;
                // count whitespace characters to determine level
                String line = lines[j];
                //logger.info("Reading option line: "+line);
                int countLevel = 1;
                int limit = line.length();
                for (int i = 0; i < limit; ++i) {
                    if (Character.isWhitespace(line.charAt(i))) {
                        ++countLevel;
                    } else {
                        break;
                    }
                }
                String translatedName = line.substring(countLevel - 1).trim();

                //logger.info("translatedName: "+translatedName);
                // build CustomAttributeLookupValue if it doesn't already exist
                CustomAttributeLookupValue lookupValue;
                if (language.getId().equalsIgnoreCase(languageId)) {
                    //logger.info("creating new lookupValue and adding to list index " + listIndex + " for " + translatedName);
                    lookupValue = new CustomAttributeLookupValue();
                    optionsList.add(lookupValue);
                } else {
                    //logger.info("trying to get lookupValue from list index " + listIndex + "for "+translatedName);
                    lookupValue = optionsList.get(listIndex);
                }
                lookupValue.setShowOrder(listIndex);
                if (language.getId().equalsIgnoreCase("en")) {
                    lookupValue.setName(translatedName);
                    lookupValue.setValue(translatedName);
                }
                lookupValue.setLevel(countLevel);

                // fix parent/child
                while ((!parents.isEmpty()) && parents.peek().getLevel() >= lookupValue.getLevel()) {
                    parents.pop();
                }
                // pile it
                if (lookupValue.getLevel() > 1) {
                    //logger.info("Adding child "+lookupValue.getName() + "to parent " +parents.peek());
                    parents.peek().addChild(lookupValue);
                }
                parents.push(lookupValue);
                // add the translation
                //logger.info("Adding lookup value "+language.getId()+" translation: "+translatedName);
                lookupValue.addNameTranslation(language.getId(), translatedName);
                //logger.info("translations afre now: "+lookupValue.getNameTranslations());

            }
        }
        //Set<CustomAttributeLookupValue> lookupValueSet = new HashSet<CustomAttributeLookupValue>();
        //lookupValueSet.addAll(optionsList);

    }
    // update attribute lookup values
    attribute.removeAllLookupValues();
    /*
    List<CustomAttributeLookupValue> toRemove = new LinkedList<CustomAttributeLookupValue>();
    for(CustomAttributeLookupValue value : attribute.getAllowedLookupValues()){
       toRemove.add(value);
    }
    attribute.removeAll(toRemove);*/
    for (CustomAttributeLookupValue value : optionsList) {
        //logger.info("Adding lookupValue  with translations: "+value.getNameTranslations());
        attribute.addAllowedLookupValue(value);
    }
    //logger.info("Added lookup values: "+attribute.getAllowedLookupValues());
}

From source file:com.intel.ssg.dcst.panthera.parse.sql.SqlParseDriver.java

/**
 * A pre-parse stage to convert the characters in query command (exclude
 * those in quotes) to lower-case, as our SQL Parser does not recognize
 * upper-case keywords. It does no harm to Hive as Hive is case-insensitive.
 *
 * @param command/*from  w  w  w.j av a 2s.  c o m*/
 *          input query command
 * @return the command with all chars turned to lower case except
 *         those in quotes
 */
protected String preparse(String command) {
    Character tag = '\'';
    Stack<Character> singleQuotes = new Stack<Character>();
    Stack<Character> doubleQuotes = new Stack<Character>();
    char[] chars = filterDot(command).toCharArray();
    for (int i = 0; i < chars.length; i++) {
        char c = chars[i];
        if (c == '\'' && (i > 0 ? chars[i - 1] != '\\' : true)) {
            singleQuotes.push(tag);
        } else if (c == '\"' && (i > 0 ? chars[i - 1] != '\\' : true)) {
            doubleQuotes.push(tag);
        }
        if (singleQuotes.size() % 2 == 0 && doubleQuotes.size() % 2 == 0) {
            // if not inside quotes, convert to lower case
            chars[i] = Character.toLowerCase(c);
        }
    }
    return new String(chars);
}

From source file:com.linecorp.armeria.common.thrift.text.TTextProtocol.java

/**
 * Create a parser which can read from trans, and create the output writer
 * that can write to a TTransport//from  w w  w .  j  a  v a  2  s .  c om
 */
public TTextProtocol(TTransport trans) {
    super(trans);

    writers = new Stack<>();
    contextStack = new Stack<>();
    currentFieldClass = new Stack<>();
    reset();
}

From source file:com.angkorteam.framework.swagger.factory.SwaggerFactory.java

@Override
public void afterPropertiesSet() throws Exception {
    Swagger swagger = new Swagger();
    io.swagger.models.Info info = new io.swagger.models.Info();
    swagger.setInfo(info);/*from   w  w  w  .  j  a v a2 s . c om*/
    info.setTitle(title);
    info.setLicense(license);
    info.setContact(contact);
    info.setTermsOfService(termsOfService);
    info.setVersion(version);
    info.setDescription(description);

    swagger.setConsumes(consumes);
    swagger.setProduces(produces);
    swagger.setSchemes(schemes);
    swagger.setBasePath(basePath);
    swagger.setHost(host);
    swagger.setExternalDocs(externalDocs);

    ConfigurationBuilder config = new ConfigurationBuilder();
    Set<String> acceptablePackages = new HashSet<>();

    boolean allowAllPackages = false;

    if (resourcePackages != null && resourcePackages.length > 0) {
        for (String resourcePackage : resourcePackages) {
            if (resourcePackage != null && !"".equals(resourcePackage)) {
                acceptablePackages.add(resourcePackage);
                config.addUrls(ClasspathHelper.forPackage(resourcePackage));
            }
        }
    }

    config.setScanners(new ResourcesScanner(), new TypeAnnotationsScanner(), new SubTypesScanner());

    Reflections reflections = new Reflections(config);
    Set<Class<?>> controllers = reflections.getTypesAnnotatedWith(Controller.class);

    Set<Class<?>> output = new HashSet<Class<?>>();
    for (Class<?> cls : controllers) {
        if (allowAllPackages) {
            output.add(cls);
        } else {
            for (String pkg : acceptablePackages) {
                if (cls.getPackage().getName().startsWith(pkg)) {
                    output.add(cls);
                }
            }
        }
    }

    Map<String, Path> paths = new HashMap<>();
    swagger.setPaths(paths);
    Map<String, Model> definitions = new HashMap<>();
    swagger.setDefinitions(definitions);
    Stack<Class<?>> modelStack = new Stack<>();
    for (Class<?> controller : controllers) {
        List<String> clazzPaths = new ArrayList<>();
        RequestMapping clazzRequestMapping = controller.getDeclaredAnnotation(RequestMapping.class);
        Api api = controller.getDeclaredAnnotation(Api.class);
        if (clazzRequestMapping != null) {
            clazzPaths = lookPaths(clazzRequestMapping);
        }
        if (clazzPaths.isEmpty()) {
            clazzPaths.add("");
        }
        if (api != null) {
            if (!"".equals(api.description())) {
                for (String name : api.tags()) {
                    if (!"".equals(name)) {
                        io.swagger.models.Tag tag = new io.swagger.models.Tag();
                        tag.setDescription(api.description());
                        tag.setName(name);
                        swagger.addTag(tag);
                    }
                }
            }
        } else {
            io.swagger.models.Tag tag = new io.swagger.models.Tag();
            tag.setDescription("Unknown");
            tag.setName("Unknown");
            swagger.addTag(tag);
        }
        Method[] methods = null;
        try {
            methods = controller.getDeclaredMethods();
        } catch (NoClassDefFoundError e) {
        }
        if (methods != null && methods.length > 0) {
            for (Method method : methods) {
                RequestMapping requestMapping = method.getAnnotation(RequestMapping.class);
                ApiOperation apiOperation = method.getAnnotation(ApiOperation.class);
                ApiResponses apiResponses = method.getAnnotation(ApiResponses.class);
                ApiHeaders apiHeaders = method.getAnnotation(ApiHeaders.class);
                List<String> methodPaths = new ArrayList<>();
                if (requestMapping != null && apiOperation != null && apiResponses != null) {
                    methodPaths = lookPaths(requestMapping);
                }
                if (methodPaths.isEmpty()) {
                    methodPaths.add("");
                }
                if (requestMapping != null && apiOperation != null && apiResponses != null) {
                    for (String classPath : clazzPaths) {
                        for (String methodPath : methodPaths) {
                            RequestMethod[] requestMethods = requestMapping.method();
                            if (requestMethods == null || requestMethods.length == 0) {
                                requestMethods = RequestMethod.values();
                            }
                            Path path = new Path();
                            paths.put(classPath + methodPath, path);
                            for (RequestMethod requestMethod : requestMethods) {
                                Operation operation = new Operation();
                                operation.setDescription(apiOperation.description());
                                for (String consume : requestMapping.consumes()) {
                                    operation.addConsumes(consume);
                                }
                                for (String produce : requestMapping.produces()) {
                                    operation.addProduces(produce);
                                }
                                if (api != null) {
                                    if (!"".equals(api.description())) {
                                        for (String name : api.tags()) {
                                            if (!"".equals(name)) {
                                                operation.addTag(name);
                                            }
                                        }
                                    }
                                } else {
                                    io.swagger.models.Tag tag = new io.swagger.models.Tag();
                                    operation.addTag("Unknown");
                                }

                                if (requestMethod == RequestMethod.DELETE) {
                                    path.delete(operation);
                                } else if (requestMethod == RequestMethod.GET) {
                                    path.get(operation);
                                } else if (requestMethod == RequestMethod.HEAD) {
                                    path.head(operation);
                                } else if (requestMethod == RequestMethod.OPTIONS) {
                                    path.options(operation);
                                } else if (requestMethod == RequestMethod.PATCH) {
                                    path.patch(operation);
                                } else if (requestMethod == RequestMethod.POST) {
                                    path.post(operation);
                                } else if (requestMethod == RequestMethod.PUT) {
                                    path.put(operation);
                                }

                                if (apiHeaders != null && apiHeaders.value() != null
                                        && apiHeaders.value().length > 0) {
                                    for (ApiHeader header : apiHeaders.value()) {
                                        HeaderParameter parameter = new HeaderParameter();
                                        parameter.setName(header.name());
                                        parameter.setType("string");
                                        parameter.setDescription(header.description());
                                        parameter.setRequired(header.required());
                                        operation.addParameter(parameter);
                                    }
                                }

                                for (Parameter parameter : method.getParameters()) {
                                    PathVariable pathVariable = parameter.getAnnotation(PathVariable.class);
                                    RequestParam requestParam = parameter.getAnnotation(RequestParam.class);
                                    RequestBody requestBody = parameter.getAnnotation(RequestBody.class);
                                    RequestPart requestPart = parameter.getAnnotation(RequestPart.class);
                                    ApiParam apiParam = parameter.getAnnotation(ApiParam.class);
                                    if (apiParam != null && pathVariable != null
                                            && isSimpleScalar(parameter.getType())) {
                                        PathParameter pathParameter = new PathParameter();
                                        pathParameter.setRequired(true);
                                        pathParameter.setDescription(apiParam.description());
                                        pathParameter.setType(lookupType(parameter.getType()));
                                        pathParameter.setFormat(lookupFormat(parameter.getType(), apiParam));
                                        pathParameter.setName(pathVariable.value());
                                        operation.addParameter(pathParameter);
                                        continue;
                                    }

                                    if (requestMethod == RequestMethod.DELETE
                                            || requestMethod == RequestMethod.GET
                                            || requestMethod == RequestMethod.HEAD
                                            || requestMethod == RequestMethod.OPTIONS
                                            || requestMethod == RequestMethod.PATCH
                                            || requestMethod == RequestMethod.PUT) {
                                        if (apiParam != null && requestParam != null
                                                && isSimpleArray(parameter.getType())) {
                                            QueryParameter param = new QueryParameter();
                                            param.setRequired(requestParam.required());
                                            param.setDescription(apiParam.description());
                                            param.setType("array");
                                            if (!"".equals(requestParam.value())) {
                                                param.setName(requestParam.value());
                                            }
                                            if (!"".equals(requestParam.name())) {
                                                param.setName(requestParam.name());
                                            }
                                            param.setItems(lookupProperty(parameter.getType(), requestParam,
                                                    apiParam));
                                            operation.addParameter(param);
                                            continue;
                                        }
                                        if (apiParam != null && requestParam != null
                                                && isSimpleScalar(parameter.getType())) {
                                            QueryParameter param = new QueryParameter();
                                            param.setRequired(requestParam.required());
                                            param.setDescription(apiParam.description());
                                            param.setType(lookupType(parameter.getType()));
                                            param.setFormat(lookupFormat(parameter.getType(), apiParam));
                                            if (!"".equals(requestParam.value())) {
                                                param.setName(requestParam.value());
                                            }
                                            if (!"".equals(requestParam.name())) {
                                                param.setName(requestParam.name());
                                            }
                                            operation.addParameter(param);
                                            continue;
                                        }
                                        if (apiParam != null && requestBody != null
                                                && parameter.getType() == MultipartFile.class) {
                                            FormParameter param = new FormParameter();
                                            param.setRequired(true);
                                            param.setIn("body");
                                            param.setName("body");
                                            param.setType("file");
                                            param.setDescription(apiParam.description());
                                            operation.addConsumes("application/octet-stream");
                                            //                                                BodyParameter param = new BodyParameter();
                                            //                                                param.setRequired(requestBody.required());
                                            //                                                param.setDescription(apiParam.description());
                                            //                                                param.setName("body");
                                            //                                                ModelImpl model = new ModelImpl();
                                            //                                                model.setType("file");
                                            //                                                param.setSchema(model);
                                            operation.addParameter(param);
                                            continue;
                                        }
                                        if (apiParam != null && requestBody != null
                                                && isSimpleArray(parameter.getType())) {
                                            BodyParameter param = new BodyParameter();
                                            param.setRequired(requestBody.required());
                                            param.setDescription(apiParam.description());
                                            param.setName("body");
                                            ArrayModel model = new ArrayModel();
                                            StringProperty property = new StringProperty();
                                            property.setType(lookupType(parameter.getType()));
                                            property.setFormat(lookupFormat(parameter.getType(), apiParam));
                                            model.setItems(property);
                                            param.setSchema(model);
                                            operation.addParameter(param);
                                            continue;
                                        }
                                        if (apiParam != null && requestBody != null
                                                && isSimpleScalar(parameter.getType())) {
                                            BodyParameter param = new BodyParameter();
                                            param.setRequired(requestBody.required());
                                            param.setDescription(apiParam.description());
                                            param.setName("body");
                                            ModelImpl model = new ModelImpl();
                                            model.setType(lookupType(parameter.getType()));
                                            model.setFormat(lookupFormat(parameter.getType(), apiParam));
                                            param.setSchema(model);
                                            operation.addParameter(param);
                                            continue;
                                        }
                                        if (apiParam != null && requestBody != null
                                                && isModelArray(parameter.getType())) {
                                            BodyParameter param = new BodyParameter();
                                            param.setRequired(requestBody.required());
                                            param.setDescription(apiParam.description());
                                            param.setName("body");
                                            ArrayModel model = new ArrayModel();
                                            RefProperty property = new RefProperty();
                                            property.setType(lookupType(parameter.getType()));
                                            property.set$ref("#/definitions/"
                                                    + parameter.getType().getComponentType().getSimpleName());
                                            if (!modelStack.contains(parameter.getType().getComponentType())) {
                                                modelStack.push(parameter.getType().getComponentType());
                                            }
                                            model.setItems(property);
                                            param.setSchema(model);
                                            operation.addParameter(param);
                                            continue;
                                        }
                                        if (apiParam != null && requestBody != null
                                                && isModelScalar(parameter.getType())) {
                                            BodyParameter param = new BodyParameter();
                                            param.setRequired(requestBody.required());
                                            param.setDescription(apiParam.description());
                                            param.setName("body");
                                            RefModel model = new RefModel();
                                            model.set$ref(
                                                    "#/definitions/" + parameter.getType().getSimpleName());
                                            if (!modelStack.contains(parameter.getType())) {
                                                modelStack.push(parameter.getType());
                                            }
                                            param.setSchema(model);
                                            operation.addParameter(param);
                                            continue;
                                        }
                                    } else if (requestMethod == RequestMethod.POST) {
                                        if (apiParam != null && requestParam != null
                                                && isSimpleArray(parameter.getType())) {
                                            FormParameter param = new FormParameter();
                                            param.setRequired(requestParam.required());
                                            param.setDescription(apiParam.description());
                                            param.setType("array");
                                            if (!"".equals(requestParam.value())) {
                                                param.setName(requestParam.value());
                                            }
                                            if (!"".equals(requestParam.name())) {
                                                param.setName(requestParam.name());
                                            }
                                            param.setItems(lookupProperty(parameter.getType(), requestParam,
                                                    apiParam));
                                            operation.addParameter(param);
                                            continue;
                                        }
                                        if (apiParam != null && requestParam != null
                                                && isSimpleScalar(parameter.getType())) {
                                            FormParameter param = new FormParameter();
                                            param.setRequired(requestParam.required());
                                            param.setDescription(apiParam.description());
                                            param.setType(lookupType(parameter.getType()));
                                            param.setFormat(lookupFormat(parameter.getType(), apiParam));
                                            if (!"".equals(requestParam.value())) {
                                                param.setName(requestParam.value());
                                            }
                                            if (!"".equals(requestParam.name())) {
                                                param.setName(requestParam.name());
                                            }
                                            operation.addParameter(param);
                                            continue;
                                        }
                                        if (apiParam != null && requestPart != null
                                                && isSimpleArray(parameter.getType())) {
                                            FormParameter param = new FormParameter();
                                            param.setRequired(requestPart.required());
                                            param.setDescription(apiParam.description());
                                            param.setType("array");
                                            if (!"".equals(requestPart.value())) {
                                                param.setName(requestPart.value());
                                            }
                                            if (!"".equals(requestPart.name())) {
                                                param.setName(requestPart.name());
                                            }
                                            param.setItems(lookupProperty(parameter.getType(), requestParam,
                                                    apiParam));
                                            operation.addParameter(param);
                                            continue;
                                        }
                                        if (apiParam != null && requestPart != null
                                                && isSimpleScalar(parameter.getType())) {
                                            FormParameter param = new FormParameter();
                                            param.setRequired(requestPart.required());
                                            param.setDescription(apiParam.description());
                                            param.setType(lookupType(parameter.getType()));
                                            param.setFormat(lookupFormat(parameter.getType(), apiParam));
                                            if (!"".equals(requestPart.value())) {
                                                param.setName(requestPart.value());
                                            }
                                            if (!"".equals(requestPart.name())) {
                                                param.setName(requestPart.name());
                                            }
                                            operation.addParameter(param);
                                            continue;
                                        }
                                    }
                                }

                                for (ApiResponse apiResponse : apiResponses.value()) {
                                    if (isSimpleScalar(apiResponse.response())) {
                                        if (apiResponse.array()) {
                                            Response response = new Response();
                                            if (!"".equals(apiResponse.description())) {
                                                response.setDescription(
                                                        apiResponse.httpStatus().getReasonPhrase());
                                            } else {
                                                response.setDescription(apiResponse.description());
                                            }
                                            ArrayProperty property = new ArrayProperty();
                                            property.setItems(
                                                    lookupProperty(apiResponse.response(), apiResponse));
                                            response.setSchema(property);
                                            operation.addResponse(
                                                    String.valueOf(apiResponse.httpStatus().value()), response);
                                        } else {
                                            Response response = new Response();
                                            if ("".equals(apiResponse.description())) {
                                                response.setDescription(
                                                        apiResponse.httpStatus().getReasonPhrase());
                                            } else {
                                                response.setDescription(apiResponse.description());
                                            }
                                            response.setSchema(
                                                    lookupProperty(apiResponse.response(), apiResponse));
                                            operation.addResponse(
                                                    String.valueOf(apiResponse.httpStatus().value()), response);
                                        }
                                    } else if (isModelScalar(apiResponse.response())) {
                                        if (apiResponse.array()) {
                                            Response response = new Response();
                                            if (!"".equals(apiResponse.description())) {
                                                response.setDescription(
                                                        apiResponse.httpStatus().getReasonPhrase());
                                            } else {
                                                response.setDescription(apiResponse.description());
                                            }
                                            RefProperty property = new RefProperty();
                                            property.set$ref(
                                                    "#/definitions/" + apiResponse.response().getSimpleName());
                                            if (!modelStack.contains(apiResponse.response())) {
                                                modelStack.push(apiResponse.response());
                                            }
                                            ArrayProperty array = new ArrayProperty();
                                            array.setItems(property);
                                            response.setSchema(array);
                                            operation.addResponse(
                                                    String.valueOf(apiResponse.httpStatus().value()), response);
                                        } else {
                                            Response response = new Response();
                                            if (!"".equals(apiResponse.description())) {
                                                response.setDescription(
                                                        apiResponse.httpStatus().getReasonPhrase());
                                            } else {
                                                response.setDescription(apiResponse.description());
                                            }
                                            RefProperty property = new RefProperty();
                                            property.set$ref(
                                                    "#/definitions/" + apiResponse.response().getSimpleName());
                                            if (!modelStack.contains(apiResponse.response())) {
                                                modelStack.push(apiResponse.response());
                                            }
                                            response.setSchema(property);
                                            operation.addResponse(
                                                    String.valueOf(apiResponse.httpStatus().value()), response);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }

    while (!modelStack.isEmpty()) {
        Class<?> scheme = modelStack.pop();
        if (definitions.containsKey(scheme.getSimpleName())) {
            continue;
        }
        java.lang.reflect.Field[] fields = scheme.getDeclaredFields();
        if (fields != null && fields.length > 0) {
            ModelImpl model = new ModelImpl();
            model.setType("object");
            for (Field field : fields) {
                ApiProperty apiProperty = field.getDeclaredAnnotation(ApiProperty.class);
                if (apiProperty != null) {
                    if (apiProperty.array()) {
                        Class<?> type = apiProperty.model();
                        ArrayProperty property = new ArrayProperty();
                        if (isSimpleScalar(type)) {
                            property.setItems(lookupProperty(type, apiProperty));
                        } else if (isModelScalar(type)) {
                            if (!definitions.containsKey(type.getSimpleName())) {
                                modelStack.push(type);
                            }
                            RefProperty ref = new RefProperty();
                            ref.set$ref("#/definitions/" + type.getSimpleName());
                            property.setItems(ref);
                        }
                        model.addProperty(field.getName(), property);
                    } else {
                        Class<?> type = field.getType();
                        if (isSimpleScalar(type)) {
                            model.addProperty(field.getName(), lookupProperty(type, apiProperty));
                        } else if (isModelScalar(type)) {
                            if (!definitions.containsKey(type.getSimpleName())) {
                                modelStack.push(type);
                            }
                            RefProperty ref = new RefProperty();
                            ref.set$ref("#/definitions/" + type.getSimpleName());
                            model.addProperty(field.getName(), ref);
                        }
                    }
                }
            }
            definitions.put(scheme.getSimpleName(), model);
        }
    }

    this.swagger = swagger;
}