001/*
002 * (C) Copyright 2008 Nuxeo SAS (http://nuxeo.com/) and contributors.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the GNU Lesser General Public License
006 * (LGPL) version 2.1 which accompanies this distribution, and is available at
007 * http://www.gnu.org/licenses/lgpl.html
008 *
009 * This library is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 * Lesser General Public License for more details.
013 *
014 * Contributors:
015 *     Nuxeo - initial API and implementation
016 *
017 * $Id: IndexingAdapterDescriptor.java 31426 2008-04-09 17:00:34Z ogrisel $
018 */
019
020package org.nuxeo.ecm.platform.indexing.gateway.adapter;
021
022import org.nuxeo.common.xmap.annotation.XNode;
023import org.nuxeo.common.xmap.annotation.XObject;
024
025@XObject("adapter")
026public class IndexingAdapterDescriptor implements Comparable<IndexingAdapterDescriptor> {
027
028    @XNode("@class")
029    private String className = "";
030
031    @XNode("@order")
032    private int order = 0;
033
034    @XNode("@enabled")
035    private boolean enabled = true;
036
037    private IndexingAdapter adapterInstance;
038
039    public String getClassName() {
040        return className;
041    }
042
043    public IndexingAdapter getAdapterInstance() {
044        return adapterInstance;
045    }
046
047    public void setAdapterInstance(IndexingAdapter adapterInstance) {
048        this.adapterInstance = adapterInstance;
049    }
050
051    public int compareTo(IndexingAdapterDescriptor o) {
052        return order - o.order;
053    }
054
055    public boolean isEnabled() {
056        return enabled;
057    }
058
059    // needed to make the following un-registration logics work:
060    // registeredAdapters.remove(registeredAdapters.lastIndexOf(descriptor));
061    @Override
062    public boolean equals(Object o) {
063        if (o instanceof IndexingAdapterDescriptor) {
064            IndexingAdapterDescriptor otherDescriptor = (IndexingAdapterDescriptor) o;
065            return className.equals(otherDescriptor.className);
066        }
067        return false;
068    }
069
070}