Example usage for java.util List contains

List of usage examples for java.util List contains

Introduction

In this page you can find the example usage for java.util List contains.

Prototype

boolean contains(Object o);

Source Link

Document

Returns true if this list contains the specified element.

Usage

From source file:Main.java

/**
 * magnify the all fonts in swing./*from  w  ww .  j  av  a  2  s.c o m*/
 * 
 * @param mag
 *            magnify parameter <br/> mag > 1. : large <br/> mag < 1. :
 *            small
 */
public static void magnifyAllFont(float mag) {
    List history = new LinkedList();
    UIDefaults defaults = UIManager.getDefaults();
    Enumeration it = defaults.keys();
    while (it.hasMoreElements()) {
        Object key = it.nextElement();
        Object a = defaults.get(key);
        if (a instanceof Font) {
            if (history.contains(a))
                continue;
            Font font = (Font) a;
            font = font.deriveFont(font.getSize2D() * mag);
            defaults.put(key, font);
            history.add(font);
        }
    }
}

From source file:org.jdal.util.BeanUtils.java

/**
 * Get PropertyValues from Object/*w  w  w. j av  a 2 s.  c  o  m*/
 * @param obj Object to get PropertyValues
 * @return the property values
 */
public static PropertyValue[] getPropertyValues(Object obj) {

    PropertyDescriptor[] pds = getPropertyDescriptors(obj.getClass());
    ArrayList<PropertyValue> pvs = new ArrayList<PropertyValue>();
    List<String> excludedProperties = Arrays.asList(EXCLUDED_PROPERTIES);

    for (int i = 0; i < pds.length; i++) {
        Object value = null;
        String name = pds[i].getName();

        if (!excludedProperties.contains(name)) {
            try {
                value = pds[i].getReadMethod().invoke(obj, (Object[]) null);
            } catch (IllegalAccessException e) {
                log.error("Error reading property name: " + name, e);
            } catch (IllegalArgumentException e) {
                log.error("Error reading property name: " + name, e);
            } catch (InvocationTargetException e) {
                log.error("Error reading property name: " + name, e);
            }
            pvs.add(new PropertyValue(name, value));
        }
    }

    return (PropertyValue[]) pvs.toArray(new PropertyValue[pvs.size()]);
}

From source file:com.ebay.cloud.cms.query.executor.SearchActionHelper.java

public static void initSortOn(SearchOption searchOption, ParseQueryNode parseNode, QueryContext queryContext,
        SearchQuery searchQuery, ISearchStrategy queryStrategy) {
    if (queryContext.hasSortOn()) {
        List<String> sortOnList = queryContext.getSortOn();
        // append default sortOn _oid
        if (!sortOnList.contains(InternalFieldEnum.ID.getName())
                && queryContext.getPaginationMode() == PaginationMode.ID_BASED) {
            sortOnList.add(InternalFieldEnum.ID.getName());
        }//from   w w  w .  j a  v a 2 s.co  m
        List<Integer> sortOrderList = new ArrayList<Integer>(sortOnList.size());
        List<ISearchField> sortOnFieldList = new ArrayList<ISearchField>(sortOnList.size());

        MetaClass metaClass = parseNode.getMetaClass();
        Map<String, GroupField> grpFields = null;
        if (parseNode.getGroup() != null) {
            grpFields = parseNode.getGroup().getGrpFields();
        }

        for (String sortFieldName : sortOnList) {
            String[] fields = sortFieldName.split("\\.");
            MetaField sortMetaField = metaClass.getFieldByName(fields[0]);
            validateSortField(sortMetaField, sortFieldName, fields, metaClass);
            //                if (sortMetaField == null) {
            //                    throw new QueryExecuteException(QueryErrCodeEnum.METAFIELD_NOT_FOUND, "Can't find sort field " + sortFieldName + " on " + metaClass.getName());
            //                }
            //                // array sort not supported
            //                if (sortMetaField.getCardinality() == CardinalityEnum.Many && fields.length == 1) {
            //                    throw new QueryExecuteException(QueryErrCodeEnum.ARRAY_SORT_NOT_SUPPORT, "Can't sort on array field " + sortFieldName + " on " + metaClass.getName());
            //                }
            //                if (sortMetaField.getDataType() == DataTypeEnum.JSON) {
            //                    throw new QueryExecuteException(QueryErrCodeEnum.JSON_SORT_NOT_SUPPORT, "Can't sort on json field " + sortFieldName + " on " + metaClass.getName());
            //                }
            String innerField = fields.length > 1
                    ? StringUtils.join(ArrayUtils.subarray(fields, 1, fields.length), '.')
                    : null;

            ISearchField sortOnField = null;
            if (grpFields != null) {
                sortOnField = grpFields.get(fields[0]);
            }

            if (sortOnField == null) {
                sortOnField = new SelectionField(sortMetaField, innerField, queryStrategy);
            }
            sortOnFieldList.add(sortOnField);

            // sortOn must be in projection for ID based pagination
            ProjectionField projField = new ProjectionField(sortMetaField, innerField, false, queryStrategy);
            if (!searchQuery.getSearchProjection().getFields().contains(projField)) {
                searchQuery.getSearchProjection().getFields().add(projField);
            }
        }
        setOrder(queryContext, sortOrderList, sortOnFieldList);
        //            if (queryContext.hasSortOrder()) {
        //                List<SortOrder> soList = queryContext.getSortOrder();
        //                for (SortOrder order : soList) {
        //                    if (order == SortOrder.asc) {
        //                        sortOrderList.add(SearchOption.ASC_ORDER);
        //                    } else {
        //                        sortOrderList.add(SearchOption.DESC_ORDER);
        //                    }
        //                }
        //            } else {
        //                // set default sort order as ascend
        //                for (int i = 0; i < sortOnFieldList.size(); i++) {
        //                    sortOrderList.add(SearchOption.ASC_ORDER);
        //                }
        //            }
        searchOption.setSortField(sortOnFieldList, sortOrderList, metaClass);
    } else {
        // sort on _oid if not given
        searchOption.setSort(Arrays.asList(InternalFieldEnum.ID.getName()),
                Arrays.asList(SearchOption.ASC_ORDER), parseNode.getMetaClass());
    }
}

From source file:hydrograph.server.execution.tracking.client.main.HydrographMain.java

/**
 * /*from   w w w  .j a va  2 s.  co m*/
 * @param argumentList
 * @return
 */
private static Optional<String> getLogLevel(List<String> argumentList) {

    if (argumentList.contains(Constants.JOB_LOG_LEVEL)) {
        return Optional.of(argumentList.get(argumentList.indexOf(Constants.JOB_LOG_LEVEL) + 1));
    }
    return Optional.empty();

}

From source file:tv.arte.resteventapi.core.presentation.decoration.RestEventApiControllerLinkBuilder.java

public static String linkTo(Class<?> controller, Method method, Map<String, ?> parameters,
        ConversionService conversionService) {

    Assert.notNull(controller, "Controller type must not be null!");
    Assert.notNull(method, "Method must not be null!");

    RestEventApiControllerLinkBuilder linkBuilder = new RestEventApiControllerLinkBuilder(getBuilder());

    if (parameters == null) {
        parameters = new HashMap<String, Object>(1);
    }//from   www .jav  a 2  s  .com

    UriTemplate template = new UriTemplate(DISCOVERER.getMapping(controller, method));
    URI uri = template.expand(parameters);
    linkBuilder = linkBuilder.slash(uri);
    List<String> templateVariables = template.getVariableNames();

    for (Entry<String, ?> paramEnt : parameters.entrySet()) {
        if (!templateVariables.contains(paramEnt.getKey())) {
            String queryParamName = paramEnt.getKey();
            Object queryParamValue = null;

            if (paramEnt.getValue() != null) {
                queryParamValue = conversionService.convert(paramEnt.getValue(), String.class);
            }

            if (queryParamValue != null) {
                linkBuilder.uriBuilder.queryParam(queryParamName, queryParamValue);
            }
        }
    }

    return linkBuilder.uriBuilder.build().toUriString();
}

From source file:com.nearinfinity.mele.zookeeper.ZookeeperIndexDeletionPolicy.java

public static List<String> getListOfReferencedFiles(ZooKeeper zk, String indexRefPath) {
    try {/*from  w  w  w .  j a v a2  s.  c o  m*/
        List<String> files = new ArrayList<String>();
        List<String> children = zk.getChildren(indexRefPath, false);
        for (String child : children) {
            String name = getName(child);
            if (!files.contains(name)) {
                files.add(name);
            }
        }
        return files;
    } catch (KeeperException e) {
        throw new RuntimeException(e);
    } catch (InterruptedException e) {
        throw new RuntimeException(e);
    }
}

From source file:com.cloudera.flume.core.EventImpl.java

/**
 * This takes an event and a list of attribute names. It returns a new event
 * that has the same core event values and all of the attribute/values
 * *except* for those attributes sepcified by the list.
 *//*ww  w .  ja v a  2s.co m*/
public static Event unselect(Event e, String... attrs) {
    Event e2 = new EventImpl(e.getBody(), e.getTimestamp(), e.getPriority(), e.getNanos(), e.getHost());
    List<String> as = Arrays.asList(attrs);
    for (Entry<String, byte[]> ent : e.getAttrs().entrySet()) {
        String a = ent.getKey();
        if (as.contains(a)) {
            continue; // don't add it if it is in the unselect list.
        }

        byte[] data = e.get(a);
        e2.set(a, data);
    }
    return e2;

}

From source file:com.dell.asm.asmcore.asmmanager.util.DeviceGroupUtil.java

/**
 * Retrieve invalid users/*from   www . j  a v a  2  s .  c om*/
 * 
 * @param entity - device group entity
 * 
 * @return invalid user ids
 */
public static Set<Long> invalidGroupUserIds(DeviceGroupEntity entity) {

    Set<Long> invalidUserIds = new HashSet<>();
    if (null == entity.getGroupsUsers())
        return invalidUserIds;

    List<Long> user_Ids = new ArrayList<Long>(entity.getGroupsUsers());
    List<Long> userList = UsersDAO.getInstance().getUsersIdById(user_Ids);

    for (Long id : user_Ids) {
        if (!userList.contains(id))
            invalidUserIds.add(id);
    }

    return invalidUserIds;
}

From source file:jenkins.plugins.shiningpanda.matrix.ToxAxis.java

/**
 * Merge the TOX environments/*  www  .j  ava  2 s  .c  o m*/
 * 
 * @param values
 *            The default values
 * @param extraValueString
 *            The custom values
 * @return The merged values
 */
private static List<String> merge(String[] values, String extraValueString) {
    // Merged values
    List<String> allValues = new ArrayList<String>();
    // Go threw the default values
    for (String value : Arrays.asList(values))
        // Check if already contained
        if (!allValues.contains(value))
            // If not add it
            allValues.add(value);
    // Parse the extra values
    for (String value : Util.tokenize(extraValueString))
        // Check if already contained
        if (!allValues.contains(value))
            // If not add it
            allValues.add(value);
    // Return the merged list
    return allValues;
}

From source file:Main.java

public static String implementProjection(List<String> columns, String[] projection,
        Map<String, String> translation) {
    List<String> localColumns = new ArrayList<String>();
    if (projection == null) {
        localColumns.addAll(columns);// ww w  . j a  v a2 s.c o  m
    } else {
        for (int i = 0; i < projection.length; i++) {
            if (columns.contains(projection[i])) {
                localColumns.add(projection[i]);
            }
        }
    }
    StringBuffer sb = new StringBuffer();
    for (int i = 0; i < localColumns.size(); i++) {
        if (i > 0) {
            sb.append(", ");
        }
        if (translation.containsKey(localColumns.get(i))) {
            sb.append(translation.get(localColumns.get(i)));
        } else {
            sb.append(localColumns.get(i));
        }
    }
    return sb.toString();
}