org.elasticsearch.client.common.XContentSource Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of elasticsearch-rest-high-level-client Show documentation
Show all versions of elasticsearch-rest-high-level-client Show documentation
Elasticsearch subproject :client:rest-high-level
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
package org.elasticsearch.client.common;
import org.elasticsearch.xcontent.ObjectPath;
import org.elasticsearch.xcontent.XContentParser;
import org.elasticsearch.xcontent.XContentUtils;
import java.io.IOException;
import java.util.List;
import java.util.Map;
/**
* Encapsulates the xcontent source
*/
public class XContentSource {
private final Object data;
/**
* Constructs a new XContentSource out of the given parser
*/
public XContentSource(XContentParser parser) throws IOException {
this.data = XContentUtils.readValue(parser, parser.nextToken());
}
/**
* @return true if the top level value of the source is a map
*/
public boolean isMap() {
return data instanceof Map;
}
/**
* @return The source as a map
*/
@SuppressWarnings("unchecked")
public Map getAsMap() {
return (Map) data;
}
/**
* @return true if the top level value of the source is a list
*/
public boolean isList() {
return data instanceof List;
}
/**
* @return The source as a list
*/
@SuppressWarnings("unchecked")
public List
© 2015 - 2024 Weber Informatics LLC | Privacy Policy