src/main/java/org/semgus/java/object/SmtTerm.java
private static SmtTerm deserializeApplication(JSONObject termDto) throws DeserializationException {
        // deserialize function identifier
        Object idDto = JsonUtils.get(termDto, "name");
        Identifier id;
        try {
            id = Identifier.deserialize(idDto);
        } catch (DeserializationException e) {
            throw e.prepend("name");
        }

        // deserialize return type identifier
        Object returnTypeDto = JsonUtils.get(termDto, "returnSort");
        Identifier returnType;
        try {
            returnType = Identifier.deserialize(returnTypeDto);
        } catch (DeserializationException e) {
            throw e.prepend("returnSort");
        }

        // zip together argument terms and argument types
        JSONArray argTypes = JsonUtils.getArray(termDto, "argumentSorts");
        JSONArray args = JsonUtils.getArray(termDto, "arguments");
        if (argTypes.size() != args.size()) {
            throw new DeserializationException(String.format(
                    "Argument sorts and arguments of SMT function application have different lengths %d != %d",
                    argTypes.size(), args.size()));
        }
        Application.TypedTerm[] argTerms = new Application.TypedTerm[argTypes.size()];
        for (int i = 0; i < argTerms.length; i++) {
            // deserialize type
            Identifier type;
            try {
                type = Identifier.deserialize(argTypes.get(i));
            } catch (DeserializationException e) {
                throw e.prepend("argumentSorts." + i);
            }

            // deserialize term
            SmtTerm term;
            try {
                term = deserialize(args.get(i));
            } catch (DeserializationException e) {
                throw e.prepend("arguments." + i);
            }

            argTerms[i] = new Application.TypedTerm(type, term);
        }

        return new Application(id, returnType, Arrays.asList(argTerms));
    }
/**
     * Deserializes a function application.
     *
     * @param termDto The JSON representation of the function application.
     * @return The deserialized function application.
     * @throws DeserializationException If {@code termDto} is not a valid representation of a function application.
     */
Deserializes a function application.
@param termDto The JSON representation of the function application.
@return The deserialized function application.
@throws DeserializationException If  termDto is not a valid representation of a function application.
Deserializes a function application . @param termDto The JSON representation of the function application . @return The deserialized function application . @throws DeserializationException If termDto is not a valid representation of a function application .
private static SmtTerm deserializeApplication(JSONObject termDto) throws DeserializationException {
        Object idDto = JsonUtils.get(termDto, "name");
        Identifier id;
        try {
            id = Identifier.deserialize(idDto);
        } catch (DeserializationException e) {
            throw e.prepend("name");
        }
        Object returnTypeDto = JsonUtils.get(termDto, "returnSort");
        Identifier returnType;
        try {
            returnType = Identifier.deserialize(returnTypeDto);
        } catch (DeserializationException e) {
            throw e.prepend("returnSort");
        }
        JSONArray argTypes = JsonUtils.getArray(termDto, "argumentSorts");
        JSONArray args = JsonUtils.getArray(termDto, "arguments");
        if (argTypes.size() != args.size()) {
            throw new DeserializationException(String.format(
                    "Argument sorts and arguments of SMT function application have different lengths %d != %d",
                    argTypes.size(), args.size()));
        }
        Application.TypedTerm[] argTerms = new Application.TypedTerm[argTypes.size()];
        for (int i = 0; i < argTerms.length; i++) {
            Identifier type;
            try {
                type = Identifier.deserialize(argTypes.get(i));
            } catch (DeserializationException e) {
                throw e.prepend("argumentSorts." + i);
            }
            SmtTerm term;
            try {
                term = deserialize(args.get(i));
            } catch (DeserializationException e) {
                throw e.prepend("arguments." + i);
            }
            argTerms[i] = new Application.TypedTerm(type, term);
        }
        return new Application(id, returnType, Arrays.asList(argTerms));
    }
private static SmtTerm deserializeApplication ( JSONObject termDto ) throws DeserializationException { Object idDto = JsonUtils . get ( termDto , "name" ) ; Identifier id ; try { id = Identifier . deserialize ( idDto ) ; } catch ( DeserializationException e ) { throw e . prepend ( "name" ) ; } Object returnTypeDto = JsonUtils . get ( termDto , "returnSort" ) ; Identifier returnType ; try { returnType = Identifier . deserialize ( returnTypeDto ) ; } catch ( DeserializationException e ) { throw e . prepend ( "returnSort" ) ; } JSONArray argTypes = JsonUtils . getArray ( termDto , "argumentSorts" ) ; JSONArray args = JsonUtils . getArray ( termDto , "arguments" ) ; if ( argTypes . size ( ) != args . size ( ) ) { throw new DeserializationException ( String . format ( "Argument sorts and arguments of SMT function application have different lengths %d != %d" , argTypes . size ( ) , args . size ( ) ) ) ; } Application . TypedTerm [ ] argTerms = new Application . TypedTerm [ argTypes . size ( ) ] ; for ( int i = 0 ; i < argTerms . length ; i ++ ) { Identifier type ; try { type = Identifier . deserialize ( argTypes . get ( i ) ) ; } catch ( DeserializationException e ) { throw e . prepend ( "argumentSorts." + i ) ; } SmtTerm term ; try { term = deserialize ( args . get ( i ) ) ; } catch ( DeserializationException e ) { throw e . prepend ( "arguments." + i ) ; } argTerms [ i ] = new Application . TypedTerm ( type , term ) ; } return new Application ( id , returnType , Arrays . asList ( argTerms ) ) ; }
Deserializes a function application.
Deserializes a function application .
// deserialize function identifier // deserialize return type identifier // zip together argument terms and argument types // deserialize type // deserialize term