com.google.api.client.util.ArrayValueMap Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of google-api-client Show documentation
Show all versions of google-api-client Show documentation
Google API Client Library for Java. Supports Java 5 (or higher) desktop (SE)
and web (EE), Android, and Google App Engine.
/*
* Copyright (c) 2011 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package com.google.api.client.util;
import com.google.common.base.Preconditions;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Map;
/**
* Collects the array values of a key/value data object, writing the fields or map values only after
* all values have been collected.
*
*
* The typical application for this is when parsing JSON or XML when the value type is known to be
* an array. It stores the values in a collection during the parsing, and only when the parsing of
* an object is finished does it convert the collection into an array and stores it.
*
*
*
* Use {@link #put(String, Class, Object)} when the destination object is a map with string keys and
* whose values accept an array of objects. Use {@link #put(Field, Class, Object)} when setting the
* value of a field using reflection, assuming its type accepts an array of objects. One can
* potentially use both {@code put} methods for example on an instance of {@link GenericData}.
*
*
* @since 1.4
* @author Yaniv Inbar
*/
public final class ArrayValueMap {
/** Array values on a particular field. */
static class ArrayValue {
/** Array component type. */
final Class> componentType;
/** Values to be stored in the array. */
final ArrayList
© 2015 - 2024 Weber Informatics LLC | Privacy Policy