Example usage for org.apache.commons.collections CollectionUtils addAll

List of usage examples for org.apache.commons.collections CollectionUtils addAll

Introduction

In this page you can find the example usage for org.apache.commons.collections CollectionUtils addAll.

Prototype

public static void addAll(Collection collection, Object[] elements) 

Source Link

Document

Adds all elements in the array to the given collection.

Usage

From source file:com.google.code.mymon3y.persistencia.dao.hibernate.AbstractGenericHibernateDAO.java

/**
 * @see #makePersistent(List)/*from   ww  w.  j a va  2  s.c om*/
 */
public List<T> makePersistent(T... entidades) throws PersistenciaMyMon3yException {

    List<T> lista = new ArrayList<T>(entidades.length);
    CollectionUtils.addAll(lista, entidades);
    return makePersistent(lista);
}

From source file:cn.fastmc.core.utils.ReflectionUtils.java

/**
 * ?DeclaredField,?./*w  ww  . jav  a  2  s  . c om*/
 * 
 * @param targetClass
 *            Class
 * @param ignoreParent
 *            ??,?Field
 * 
 * @return List
 */
public static List<Field> getAccessibleFields(final Class targetClass, final boolean ignoreParent) {
    Assert.notNull(targetClass, "targetClass?");
    List<Field> fields = new ArrayList<Field>();

    Class<?> sc = targetClass;

    do {
        Field[] result = sc.getDeclaredFields();

        if (!ArrayUtils.isEmpty(result)) {

            for (Field field : result) {
                field.setAccessible(true);
            }

            CollectionUtils.addAll(fields, result);
        }

        sc = sc.getSuperclass();

    } while (sc != Object.class && !ignoreParent);

    return fields;
}

From source file:com.leadtone.riders.utils.ReflectionUtils.java

/**
 * ?, ?DeclaredField./* w w w  .jav a2  s  .c o  m*/
 * 
 * ?Object?, null.
 * @param <T>
 */
public static <T> List<String> getDeclaredFieldNames(final Class<T> c) {
    List<Field> list = new ArrayList<Field>();
    List<String> nameList = new ArrayList<String>();
    for (Class<?> superClass = c; superClass != Object.class; superClass = superClass.getSuperclass()) {
        CollectionUtils.addAll(list, superClass.getDeclaredFields());
    }
    for (Field field : list) {
        nameList.add(field.getName());
    }
    return nameList;
}

From source file:gov.nih.nci.firebird.web.action.user.registration.flow.SponsorOrganizationsPageFlowActionTest.java

@Test
public void testSaveAndProceedPrevious() {
    CollectionUtils.addAll(action.getSelectedSponsors(), new Long[] { 1L, 2L });
    action.saveAndProceedPrevious();//from   w  w w.ja v a 2 s  . c o  m
    assertTrue(action.getSelectedSponsorExternalIds().isEmpty());
}

From source file:com.glodon.paas.document.api.FileRestAPITest.java

@Test
public void getProjectFilePrivilege() throws Exception {
    File pFile = createSimpleProject("");
    File c = getFile(/*  www  .  j  a  v a  2  s.c o  m*/
            simpleCall(createPost("/project/" + pFile.getProjectId() + "/file/1/2/3?folder")),
            null);
    String str = simpleCall(createGet("/file/" + pFile.getId() + "?privilege"));
    Map<String, String[]> map = this.convertString2Obj(str, new TypeReference<Map<String, String[]>>() {
    });
    Set<String> pv = new HashSet<String>();
    CollectionUtils.addAll(pv, map.get("privilege"));
    assertEquals(4, pv.size());
    assertTrue(pv.contains("x"));
    assertTrue(pv.contains("r"));
    assertTrue(pv.contains("w"));
    assertTrue(pv.contains("d"));

    str = simpleCall(createGet("/file/" + c.getId() + "?privilege"));
    map = this.convertString2Obj(str, new TypeReference<Map<String, String[]>>() {
    });
    pv = new HashSet<String>();
    CollectionUtils.addAll(pv, map.get("privilege"));
    assertEquals(3, pv.size());
    assertTrue(pv.contains("i-r"));
    assertTrue(pv.contains("i-w"));
    assertTrue(pv.contains("i-d"));
}

From source file:cn.fastmc.core.utils.ReflectionUtils.java

/**
 * ?DeclaredMethod ?./*from w w  w . j  av a2s.c o  m*/
 * 
 * @param targetClass
 *            Class
 * @param ignoreParent
 *            ??,?Method
 * 
 * @return List
 */
public static List<Method> getAccessibleMethods(final Class targetClass, boolean ignoreParent) {
    Assert.notNull(targetClass, "targetClass?");
    List<Method> methods = new ArrayList<Method>();

    Class<?> superClass = targetClass;
    do {
        Method[] result = superClass.getDeclaredMethods();

        if (!ArrayUtils.isEmpty(result)) {

            for (Method method : result) {
                method.setAccessible(true);
            }

            CollectionUtils.addAll(methods, result);
        }

        superClass = superClass.getSuperclass();
    } while (superClass != Object.class && !ignoreParent);

    return methods;
}

From source file:com.baidu.rigel.biplatform.ma.report.utils.QueryUtils.java

/**
 * ??/*from ww w  .  j a  v a  2  s  .co  m*/
 * 
 * @param reportModel
 * @param area
 * @param queryAction
 * @return
 * @throws QueryModelBuildException
 */
private static Map<String, MetaCondition> buildQueryConditions(ReportDesignModel reportModel, ExtendArea area,
        QueryAction queryAction) throws QueryModelBuildException {
    Map<String, MetaCondition> rs = new HashMap<String, MetaCondition>();
    Map<Item, Object> items = new HashMap<Item, Object>();
    items.putAll(queryAction.getColumns());
    items.putAll(queryAction.getRows());
    items.putAll(queryAction.getSlices());
    int firstIndex = 0;
    for (Map.Entry<Item, Object> entry : items.entrySet()) {
        Item item = entry.getKey();
        OlapElement olapElement = ReportDesignModelUtils.getDimOrIndDefineWithId(reportModel.getSchema(),
                area.getCubeId(), item.getOlapElementId());
        if (olapElement == null) {
            Cube cube = com.baidu.rigel.biplatform.ma.report.utils.QueryUtils.getCubeWithExtendArea(reportModel,
                    area);
            for (Dimension dim : cube.getDimensions().values()) {
                if (dim.getId().equals(item.getOlapElementId())) {
                    olapElement = dim;
                    break;
                }
            }
        }
        if (olapElement == null) {
            continue;
        }
        if (olapElement instanceof Dimension) {
            DimensionCondition condition = new DimensionCondition(olapElement.getName());
            Object valueObj = entry.getValue();
            if (valueObj != null) {
                List<String> values = Lists.newArrayList();
                if (valueObj instanceof String[]) {
                    values = Lists.newArrayList();
                    String[] tmp = resetValues(olapElement.getName(), (String[]) valueObj);
                    CollectionUtils.addAll(values, (String[]) tmp);
                } else {
                    String tmp = resetValues(olapElement.getName(), valueObj.toString())[0];
                    values.add(tmp);
                }

                List<QueryData> datas = Lists.newArrayList();
                // TODO ?UniqueName?
                String rootUniqueName = "[" + olapElement.getName() + "].[All_" + olapElement.getName();
                // TODO QeuryData value?
                for (String value : values) {
                    if (!queryAction.isChartQuery() && value.indexOf(rootUniqueName) != -1) {
                        datas.clear();
                        break;
                    }
                    QueryData data = new QueryData(value);
                    Object drillValue = queryAction.getDrillDimValues().get(item);
                    String tmpValue = null;
                    if (valueObj instanceof String[]) {
                        tmpValue = ((String[]) valueObj)[0];
                    } else {
                        tmpValue = valueObj.toString();
                    }
                    if (drillValue != null && tmpValue.equals(drillValue)) {
                        data.setExpand(true);
                    } else if ((item.getPositionType() == PositionType.X
                            || item.getPositionType() == PositionType.S) && queryAction.isChartQuery()) {
                        data.setExpand(true);
                        data.setShow(false);
                    }
                    // ?
                    if (item.getParams().get(Constants.LEVEL) != null) {
                        if (item.getParams().get(Constants.LEVEL).equals(1)) {
                            data.setExpand(!queryAction.isChartQuery());
                            data.setShow(true);
                        } else if (item.getParams().get(Constants.LEVEL).equals(2)) {
                            data.setExpand(true);
                            data.setShow(false);
                        }
                        if (MetaNameUtil.isAllMemberUniqueName(data.getUniqueName())
                                && queryAction.isChartQuery()) {
                            data.setExpand(true);
                            data.setShow(false);
                        }
                    }
                    datas.add(data);
                }
                if (values.isEmpty() && queryAction.isChartQuery()) {
                    QueryData data = new QueryData(rootUniqueName + "s]");
                    data.setExpand(true);
                    data.setShow(false);
                    datas.add(data);
                }
                condition.setQueryDataNodes(datas);
            } else {
                List<QueryData> datas = new ArrayList<QueryData>();
                Dimension dim = (Dimension) olapElement;
                if ((item.getPositionType() == PositionType.X || item.getPositionType() == PositionType.S)
                        && queryAction.isChartQuery()) {
                    QueryData data = new QueryData(dim.getAllMember().getUniqueName());
                    data.setExpand(true);
                    data.setShow(false);
                    datas.add(data);
                } else if (dim.getType() == DimensionType.CALLBACK) {
                    QueryData data = new QueryData(dim.getAllMember().getUniqueName());
                    data.setExpand(firstIndex == 0);
                    data.setShow(firstIndex != 0);
                    datas.add(data);
                }
                condition.setQueryDataNodes(datas);
            }
            // ??????
            if (item.getPositionType() == PositionType.X && olapElement instanceof TimeDimension
                    && firstIndex == 0 && !queryAction.isChartQuery()) {
                condition.setMemberSortType(SortType.DESC);
                ++firstIndex;
            }
            rs.put(condition.getMetaName(), condition);
        }
    }
    return rs;
}

From source file:com.zc.util.refelect.Reflector.java

/**
 *
 * ?annotationClass//from  w  w w  . jav  a2s  .c  om
 *
 * @param targetClass
 *            Class
 * @param annotationClass
 *            Class
 *
 * @return List
 */
public static <T extends Annotation> List<T> getAnnotations(Class targetClass, Class annotationClass) {

    List<T> result = new ArrayList<T>();
    Annotation annotation = targetClass.getAnnotation(annotationClass);
    if (annotation != null) {
        result.add((T) annotation);
    }
    Constructor[] constructors = targetClass.getDeclaredConstructors();
    // ?
    CollectionUtils.addAll(result, getAnnotations(constructors, annotationClass).iterator());

    Field[] fields = targetClass.getDeclaredFields();
    // ?
    CollectionUtils.addAll(result, getAnnotations(fields, annotationClass).iterator());

    Method[] methods = targetClass.getDeclaredMethods();
    // ?
    CollectionUtils.addAll(result, getAnnotations(methods, annotationClass).iterator());

    for (Class<?> superClass = targetClass.getSuperclass(); superClass == null
            || superClass == Object.class; superClass = superClass.getSuperclass()) {
        List<T> temp = (List<T>) getAnnotations(superClass, annotationClass);
        if (CollectionUtils.isNotEmpty(temp)) {
            CollectionUtils.addAll(result, temp.iterator());
        }
    }

    return result;
}

From source file:cn.fastmc.core.utils.ReflectionUtils.java

/**
 * /*from w w  w . j a va 2 s.  c  o m*/
 * ?annotationClass
 * 
 * @param targetClass
 *            Class
 * @param annotationClass
 *            Class
 * 
 * @return List
 */
public static <T extends Annotation> List<T> getAnnotations(Class targetClass, Class annotationClass) {
    Assert.notNull(targetClass, "targetClass?");
    Assert.notNull(annotationClass, "annotationClass?");

    List<T> result = new ArrayList<T>();
    Annotation annotation = targetClass.getAnnotation(annotationClass);
    if (annotation != null) {
        result.add((T) annotation);
    }
    Constructor[] constructors = targetClass.getDeclaredConstructors();
    // ?
    CollectionUtils.addAll(result, getAnnotations(constructors, annotationClass).iterator());

    Field[] fields = targetClass.getDeclaredFields();
    // ?
    CollectionUtils.addAll(result, getAnnotations(fields, annotationClass).iterator());

    Method[] methods = targetClass.getDeclaredMethods();
    // ?
    CollectionUtils.addAll(result, getAnnotations(methods, annotationClass).iterator());

    for (Class<?> superClass = targetClass.getSuperclass(); superClass == null
            || superClass == Object.class; superClass = superClass.getSuperclass()) {
        List<T> temp = getAnnotations(superClass, annotationClass);
        if (CollectionUtils.isNotEmpty(temp)) {
            CollectionUtils.addAll(result, temp.iterator());
        }
    }

    return result;
}

From source file:com.liangc.hq.base.utils.BizappUtils.java

public static List sortAppdefResourceType(List resourceType) {
    List sortedList = new ArrayList();
    SortedSet sSet = new TreeSet(COMPARE_NAME);
    sSet.addAll(resourceType);/*from  w w  w. j  av a2s  . c o  m*/
    CollectionUtils.addAll(sortedList, sSet.iterator());
    return sortedList;
}