Example usage for java.util List equals

List of usage examples for java.util List equals

Introduction

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

Prototype

boolean equals(Object o);

Source Link

Document

Compares the specified object with this list for equality.

Usage

From source file:org.datanucleus.ide.idea.ui.DNEConfigForm.java

public boolean isModified() {
    final GuiState before = this.guiStateBeforeChanges;
    if (this.enableEnhancerCheckBox.isSelected() != before.isEnhancerEnabled()) {
        return true;
    }/*  ww  w  .ja v  a  2  s .  com*/
    final String metadataExtensionTextFieldText = this.metadataExtensionTextField.getText();
    if (metadataExtensionTextFieldText != null
            ? !metadataExtensionTextFieldText.trim().equals(before.getMetaDataExtensions())
                    && !containsDisabledTokens(metadataExtensionTextFieldText)
            : before.getMetaDataExtensions() != null && !before.getMetaDataExtensions().trim().isEmpty()) {
        return true;
    }
    if (this.addToCompilerResourceCheckBox.isSelected() != before.isAddToCompilerResourcePatterns()) {
        return true;
    }
    if (this.includeTestClassesCheckBox.isSelected() != before.isIncludeTestClasses()) {
        return true;
    }
    if (!this.jDORadioButton.isSelected() && PersistenceApi.JDO == before.getApi()) {
        return true;
    }
    if (!this.jPARadioButton.isSelected() && PersistenceApi.JPA == before.getApi()) {
        return true;
    }

    final EnhancerSupport enhancerSupport = getByEnhancerSupportName(before,
            (String) this.persistenceImplComboBox.getSelectedItem());
    if (!before.getEnhancerSupport().getId().equals(enhancerSupport.getId())) {
        return true;
    }

    final PersistenceApi selectedApi = this.jDORadioButton.isSelected() ? PersistenceApi.JDO
            : PersistenceApi.JPA;
    if (before.getApi() != selectedApi) {
        return true;
    }

    if (before.isDependenciesManual() != this.depManualRadioButton.isSelected()) {
        return true;
    }

    if (!before.getDependencies().equals(this.dependenciesAddDeletePanel.getDependencies())) {
        return true;
    }

    final AffectedModulesRowModel affectedModulesRowModel = (AffectedModulesRowModel) this.affectedModulesTable
            .getModel();
    final List<AffectedModule> affectedModules = affectedModulesRowModel.getAffectedModules();
    return affectedModules != null ? !affectedModules.equals(before.getAffectedModules())
            : before.getAffectedModules() != null;
}

From source file:org.nuxeo.search.ui.seam.SearchUIActions.java

@Observer(value = USER_ALL_DOCUMENT_TYPES_SELECTION_CHANGED)
public void invalidateContentViewsNameIfChanged() {
    List<ContentViewHeader> temp = new ArrayList<>(
            Framework.getService(SearchUIService.class).getContentViewHeaders(
                    actionContextProvider.createActionContext(), navigationContext.getCurrentDocument()));
    if (temp != null) {
        if (!temp.equals(contentViewHeaders)) {
            invalidateContentViewsName();
        }//from   ww w.j  a  v a2  s.c om
        if (!temp.isEmpty()) {
            String s = temp.get(0).getName();
            if (s != null && !s.equals(currentContentViewName)) {
                invalidateContentViewsName();
            }
        }
    }
}

From source file:org.apache.hadoop.hive.ql.parse.ImportSemanticAnalyzer.java

private static void checkTable(Table table, ImportTableDesc tableDesc, ReplicationSpec replicationSpec,
        HiveConf conf) throws SemanticException, URISyntaxException {
    // This method gets called only in the scope that a destination table already exists, so
    // we're validating if the table is an appropriate destination to import into

    if (replicationSpec.isInReplicationScope()) {
        // If this import is being done for replication, then this will be a managed table, and replacements
        // are allowed irrespective of what the table currently looks like. So no more checks are necessary.
        return;//from w  ww .  j a  v a 2s. c  om
    } else {
        // verify if table has been the target of replication, and if so, check HiveConf if we're allowed
        // to override. If not, fail.
        if (table.getParameters().containsKey(ReplicationSpec.KEY.CURR_STATE_ID.toString())
                && conf.getBoolVar(HiveConf.ConfVars.HIVE_EXIM_RESTRICT_IMPORTS_INTO_REPLICATED_TABLES)) {
            throw new SemanticException(ErrorMsg.IMPORT_INTO_STRICT_REPL_TABLE
                    .getMsg("Table " + table.getTableName() + " has repl.last.id parameter set."));
        }
    }

    // Next, we verify that the destination table is not offline, or a non-native table
    EximUtil.validateTable(table);

    // If the import statement specified that we're importing to an external
    // table, we seem to be doing the following:
    //    a) We don't allow replacement in an unpartitioned pre-existing table
    //    b) We don't allow replacement in a partitioned pre-existing table where that table is external
    // TODO : Does this simply mean we don't allow replacement in external tables if they already exist?
    //    If so(i.e. the check is superfluous and wrong), this can be a simpler check. If not, then
    //    what we seem to be saying is that the only case we allow is to allow an IMPORT into an EXTERNAL
    //    table in the statement, if a destination partitioned table exists, so long as it is actually
    //    not external itself. Is that the case? Why?
    {
        if ((tableDesc.isExternal()) // IMPORT statement speicified EXTERNAL
                && (!table.isPartitioned() || !table.getTableType().equals(TableType.EXTERNAL_TABLE))) {
            throw new SemanticException(ErrorMsg.INCOMPATIBLE_SCHEMA
                    .getMsg(" External table cannot overwrite existing table. Drop existing table first."));
        }
    }

    // If a table import statement specified a location and the table(unpartitioned)
    // already exists, ensure that the locations are the same.
    // Partitioned tables not checked here, since the location provided would need
    // checking against the partition in question instead.
    {
        if ((tableDesc.getLocation() != null) && (!table.isPartitioned())
                && (!table.getDataLocation().equals(new Path(tableDesc.getLocation())))) {
            throw new SemanticException(ErrorMsg.INCOMPATIBLE_SCHEMA.getMsg(" Location does not match"));

        }
    }
    {
        // check column order and types
        List<FieldSchema> existingTableCols = table.getCols();
        List<FieldSchema> importedTableCols = tableDesc.getCols();
        if (!EximUtil.schemaCompare(importedTableCols, existingTableCols)) {
            throw new SemanticException(ErrorMsg.INCOMPATIBLE_SCHEMA.getMsg(" Column Schema does not match"));
        }
    }
    {
        // check partitioning column order and types
        List<FieldSchema> existingTablePartCols = table.getPartCols();
        List<FieldSchema> importedTablePartCols = tableDesc.getPartCols();
        if (!EximUtil.schemaCompare(importedTablePartCols, existingTablePartCols)) {
            throw new SemanticException(
                    ErrorMsg.INCOMPATIBLE_SCHEMA.getMsg(" Partition Schema does not match"));
        }
    }
    {
        // check table params
        Map<String, String> existingTableParams = table.getParameters();
        Map<String, String> importedTableParams = tableDesc.getTblProps();
        String error = checkParams(existingTableParams, importedTableParams,
                new String[] { "howl.isd", "howl.osd" });
        if (error != null) {
            throw new SemanticException(
                    ErrorMsg.INCOMPATIBLE_SCHEMA.getMsg(" Table parameters do not match: " + error));
        }
    }
    {
        // check IF/OF/Serde
        String existingifc = table.getInputFormatClass().getName();
        String importedifc = tableDesc.getInputFormat();
        String existingofc = table.getOutputFormatClass().getName();
        String importedofc = tableDesc.getOutputFormat();
        /*
         * substitute OutputFormat name based on HiveFileFormatUtils.outputFormatSubstituteMap
         */
        try {
            Class<?> origin = Class.forName(importedofc, true, Utilities.getSessionSpecifiedClassLoader());
            Class<? extends OutputFormat> replaced = HiveFileFormatUtils.getOutputFormatSubstitute(origin);
            if (replaced == null) {
                throw new SemanticException(ErrorMsg.INVALID_OUTPUT_FORMAT_TYPE.getMsg());
            }
            importedofc = replaced.getCanonicalName();
        } catch (Exception e) {
            throw new SemanticException(ErrorMsg.INVALID_OUTPUT_FORMAT_TYPE.getMsg());
        }
        if ((!existingifc.equals(importedifc)) || (!existingofc.equals(importedofc))) {
            throw new SemanticException(
                    ErrorMsg.INCOMPATIBLE_SCHEMA.getMsg(" Table inputformat/outputformats do not match"));
        }
        String existingSerde = table.getSerializationLib();
        String importedSerde = tableDesc.getSerName();
        if (!existingSerde.equals(importedSerde)) {
            throw new SemanticException(
                    ErrorMsg.INCOMPATIBLE_SCHEMA.getMsg(" Table Serde class does not match"));
        }
        String existingSerdeFormat = table.getSerdeParam(serdeConstants.SERIALIZATION_FORMAT);
        String importedSerdeFormat = tableDesc.getSerdeProps().get(serdeConstants.SERIALIZATION_FORMAT);
        /*
         * If Imported SerdeFormat is null, then set it to "1" just as
         * metadata.Table.getEmptyTable
         */
        importedSerdeFormat = importedSerdeFormat == null ? "1" : importedSerdeFormat;
        if (!ObjectUtils.equals(existingSerdeFormat, importedSerdeFormat)) {
            throw new SemanticException(
                    ErrorMsg.INCOMPATIBLE_SCHEMA.getMsg(" Table Serde format does not match"));
        }
    }
    {
        // check bucket/sort cols
        if (!ObjectUtils.equals(table.getBucketCols(), tableDesc.getBucketCols())) {
            throw new SemanticException(
                    ErrorMsg.INCOMPATIBLE_SCHEMA.getMsg(" Table bucketing spec does not match"));
        }
        List<Order> existingOrder = table.getSortCols();
        List<Order> importedOrder = tableDesc.getSortCols();
        // safely sorting
        final class OrderComparator implements Comparator<Order> {
            @Override
            public int compare(Order o1, Order o2) {
                if (o1.getOrder() < o2.getOrder()) {
                    return -1;
                } else {
                    if (o1.getOrder() == o2.getOrder()) {
                        return 0;
                    } else {
                        return 1;
                    }
                }
            }
        }
        if (existingOrder != null) {
            if (importedOrder != null) {
                Collections.sort(existingOrder, new OrderComparator());
                Collections.sort(importedOrder, new OrderComparator());
                if (!existingOrder.equals(importedOrder)) {
                    throw new SemanticException(
                            ErrorMsg.INCOMPATIBLE_SCHEMA.getMsg(" Table sorting spec does not match"));
                }
            }
        } else {
            if (importedOrder != null) {
                throw new SemanticException(
                        ErrorMsg.INCOMPATIBLE_SCHEMA.getMsg(" Table sorting spec does not match"));
            }
        }
    }
}

From source file:org.onosproject.drivers.fujitsu.FujitsuVoltControllerConfigTest.java

/**
 * Run to verify handling of valid get operation.
 *//*from w ww  .j ava  2s. c om*/
@Test
public void testGetControllers() throws Exception {
    List<ControllerInfo> controllers;
    List<ControllerInfo> expectedControllers = new ArrayList<>();

    for (int i = ZERO; i < GET_CONTROLLERS.length; i++) {
        String target = GET_CONTROLLERS[i];
        String[] data = target.split(TEST_COLON);
        currentKey = i + ONE;

        Annotations annotations = DefaultAnnotations.builder().set(TEST_OFCONFIG_ID, currentKey.toString())
                .build();
        ControllerInfo controller = new ControllerInfo(IpAddress.valueOf(data[SECOND_PART]),
                Integer.parseInt(data[THIRD_PART]), data[FIRST_PART], annotations);
        expectedControllers.add(controller);
    }

    controllers = voltConfig.getControllers();
    assertTrue("Incorrect response", controllers.equals(expectedControllers));
}

From source file:org.jahia.services.content.JCRStoreService.java

public void reloadNodeTypeRegistry() throws RepositoryException {
    List<String> filesList = new ArrayList<>();
    List<String> remfiles;

    NodeTypeRegistry instance = NodeTypeRegistry.getInstance();

    logger.info("Loading all CNDs from DB ..");
    remfiles = new ArrayList<>(nodeTypesDBService.getFilesList());
    List<String> reloadedSystemIds = new ArrayList<>();
    while (!remfiles.isEmpty() && !remfiles.equals(filesList)) {
        filesList = new ArrayList<>(remfiles);
        remfiles.clear();/*from  w ww .  j  a  v a  2s .co m*/
        for (final String file : filesList) {
            try {
                if (file.endsWith(".cnd")) {
                    final String cndFile = nodeTypesDBService.readFile(file);
                    final String systemId = StringUtils.substringBeforeLast(file, ".cnd");
                    if (!initializedSystemIds.contains(systemId)) {
                        logger.debug("Loading CND : {}", file);
                        instance.addDefinitionsFile(new ByteArrayResource(cndFile.getBytes("UTF-8"), file),
                                systemId);
                    }
                    reloadedSystemIds.add(systemId);
                }
            } catch (ParseException | NoSuchNodeTypeException e) {
                logger.debug(file + " cannot be parsed, reorder later");
                remfiles.add(file);
            } catch (IOException e) {
                logger.error("Cannot parse CND file from DB : " + file, e);
            }
        }
    }

    List<String> systemIds = NodeTypeRegistry.getInstance().getSystemIds();
    systemIds.removeAll(reloadedSystemIds);
    for (String systemId : systemIds) {
        NodeTypeRegistry.getInstance().unregisterNodeTypes(systemId);
    }
    if (!remfiles.isEmpty()) {
        logger.error("Cannot read CND from : " + remfiles);
    }

    registerNamespaces();
}

From source file:com.datascience.cascading.CsvSchemeTest.java

/**
 * Tests the content of an output path against the given expected path.
 *///from  w  w  w .  j ava 2 s  .c o m
@SuppressWarnings("unchecked")
private void testPaths(String actual, String expected) throws Exception {

    Tap outputTest = new Hfs(new TextLine(), actual);
    Tap expectedTest = new Hfs(new TextLine(), expected);

    FlowProcess outputProcess = new HadoopFlowProcess(new JobConf(new Configuration()));
    FlowProcess expectedProcess = new HadoopFlowProcess(new JobConf(new Configuration()));

    TupleEntryIterator outputIterator = outputTest.openForRead(outputProcess);
    TupleEntryIterator expectedIterator = expectedTest.openForRead(expectedProcess);

    List<String> outputList = new ArrayList<>();
    while (outputIterator.hasNext()) {
        outputList.add(outputIterator.next().getTuple().getString(1));
    }

    List<String> expectedList = new ArrayList<>();
    while (expectedIterator.hasNext()) {
        expectedList.add(expectedIterator.next().getTuple().getString(1));
    }

    assertTrue(outputList.equals(expectedList));

}

From source file:me.ccrama.redditslide.DragSort.ReorderSubreddits.java

public void doAddSub(String subreddit) {
    subreddit = subreddit.toLowerCase();
    List<String> sortedSubs = UserSubscriptions.sortNoExtras(subs);

    if (sortedSubs.equals(subs)) {
        subs.add(subreddit);//from   w ww  .j  av a2 s .c om
        subs = UserSubscriptions.sortNoExtras(subs);
        adapter = new CustomAdapter(subs);
        recyclerView.setAdapter(adapter);
    } else {
        int pos = addSubAlphabetically(subreddit);
        adapter.notifyDataSetChanged();
        recyclerView.smoothScrollToPosition(pos);
    }
}

From source file:com.bt.download.android.gui.adapters.TransferListAdapter.java

public TransferListAdapter(Context context, List<Transfer> list) {
    this.context = new WeakReference<Context>(context);

    this.viewOnClickListener = new ViewOnClickListener();
    this.viewOnLongClickListener = new ViewOnLongClickListener();
    this.playOnClickListener = new OpenOnClickListener();

    this.dialogs = new ArrayList<Dialog>();

    this.list = list.equals(Collections.emptyList()) ? new ArrayList<Transfer>() : list;

    initTransferStateStringMap();/*  w w w .j  av a  2s . c  om*/
}

From source file:gate.creole.gazetteer.GazetteerList.java

/**
 * Updates the content of the gaz list with the given parameter.
 * Depends on the mode of the gaz list. In the case of
 * {@link #LIST_MODE} the new content is parsed and loaded as single
 * nodes through the {@link java.util.List} interface. In the case of
 * {@link #STRING_MODE} the new content is stored as a String and is
 * not parsed./*from   w  w  w. j  av a  2  s . co m*/
 * 
 * @param newContent the new content of the gazetteer list
 */
public void updateContent(String newContent) {
    switch (mode) {
    case STRING_MODE: {
        content = newContent;
        break;
    }
    case LIST_MODE: {
        BufferedReader listReader;
        listReader = new BufferedReader(new StringReader(newContent));
        String line;
        List<GazetteerNode> tempEntries = new ArrayList<GazetteerNode>();
        try {
            while (null != (line = listReader.readLine())) {
                tempEntries.add(new GazetteerNode(line, separator));
            } // while
            listReader.close();
        } catch (IOException x) {
            /** should never be thrown */
            throw new gate.util.LuckyException("IOException :" + x.getMessage());
        }

        isModified = !tempEntries.equals(entries);
        clear();
        entries = tempEntries;
        break;
    } // LIST_MODE
    default: {
        throw new gate.util.GateRuntimeException("Invalid Mode =" + mode + "\nValid modes are:\nLIST_MODE = "
                + LIST_MODE + "\nSTRING_MODE = " + STRING_MODE);
    } // default
    } // switch mode
}

From source file:regexgaz.GazetteerList.java

/**
 * Updates the content of the gaz list with the given parameter. Depends on
 * the mode of the gaz list. In the case of {@link #LIST_MODE} the new
 * content is parsed and loaded as single nodes through the
 * {@link java.util.List} interface. In the case of {@link #STRING_MODE} the
 * new content is stored as a String and is not parsed.
 *
 * @param newContent the new content of the gazetteer list
 *//*from ww  w  .ja va  2 s .co  m*/
public void updateContent(String newContent) {
    switch (mode) {
    case STRING_MODE: {
        content = newContent;
        break;
    }
    case LIST_MODE: {
        BufferedReader listReader;
        listReader = new BufferedReader(new StringReader(newContent));
        String line;
        List<GazetteerNode> tempEntries = new ArrayList<>();
        try {
            while (null != (line = listReader.readLine())) {
                tempEntries.add(new GazetteerNode(line, separator));
            } // while
            listReader.close();
        } catch (IOException x) {
            /**
             * should never be thrown
             */
            throw new LuckyException("IOException :" + x.getMessage());
        }

        isModified = !tempEntries.equals(entries);
        clear();
        entries = tempEntries;
        break;
    } // LIST_MODE
    default: {
        throw new GateRuntimeException("Invalid Mode =" + mode + "\nValid modes are:\nLIST_MODE = " + LIST_MODE
                + "\nSTRING_MODE = " + STRING_MODE);
    }
    } // switch mode
}