Code example for Gson

Methods: toJson

0
     * @param definition Stream definition object which should be added 
     */ 
 
    public void addStreamDefinition(StreamDefinition definition) {
        String key = DataPublisherUtil.getStreamCacheKey(definition.getName(), definition.getVersion());
        streamDefnCache.put(key, gson.toJson(definition));
    } 
 
    /** 
     * Returns a boolean whether the stream definition is already 
     * added to cache in async data publisher 
     * 
     * @param streamName Name of the stream needed to check 
     * @param version    version of the stream needed to check 
     * @return whether the stream definition is exists or not 
     */ 
    public boolean isStreamDefinitionAdded(String streamName, String version) {
        String key = DataPublisherUtil.getStreamCacheKey(streamName, version);
        return null != streamDefnCache.get(key);
    } 
Experience pair programming with AI  Get Codota for Java