org.apache.juneau.objecttools.ObjectViewer Maven / Gradle / Ivy
// ***************************************************************************************************************************
// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
// * to you 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 org.apache.juneau.objecttools;
import static org.apache.juneau.internal.CollectionUtils.*;
import java.lang.reflect.*;
import java.util.*;
import org.apache.juneau.*;
import org.apache.juneau.internal.*;
/**
* POJO model viewer.
*
*
* This class is designed to extract properties from collections of maps or beans.
*
*
* Example:
*
* MyBean[] arrayOfBeans = ...;
* ObjectViewer viewer = ObjectViewer.create ();
*
* // Returns the 'foo' and 'bar' properties extracted into a list of maps.
* List<Map> result = viewer .run(arrayOfBeans , "foo,bar" );
*
*
* The tool can be used against the following data types:
*
*
* - Arrays/collections of maps or beans.
*
- Singular maps or beans.
*
*
* See Also:
*/
@SuppressWarnings({"unchecked","rawtypes"})
public final class ObjectViewer implements ObjectTool {
//-----------------------------------------------------------------------------------------------------------------
// Static
//-----------------------------------------------------------------------------------------------------------------
/**
* Default reusable searcher.
*/
public static final ObjectViewer DEFAULT = new ObjectViewer();
/**
* Static creator.
*
* @return A new {@link ObjectViewer} object.
*/
public static ObjectViewer create() {
return new ObjectViewer();
}
//-----------------------------------------------------------------------------------------------------------------
// Instance
//-----------------------------------------------------------------------------------------------------------------
/**
* Runs this viewer on the specified collection or array of objects.
*
* @param input The input. Must be an array or collection.
* @param args The view args. See {@link ViewArgs} for format.
* @return The extracted properties from the collection of objects.
*/
public List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy