001/*
002 * (C) Copyright 2013 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     Antoine Taillefer <ataillefer@nuxeo.com>
018 */
019package org.nuxeo.drive.service.impl;
020
021import java.io.Serializable;
022
023import org.nuxeo.common.xmap.annotation.XNode;
024import org.nuxeo.common.xmap.annotation.XObject;
025
026/**
027 * XMap descriptor for the {@code factory} elements of the {@code activeFileSystemItemFactories} contributions.
028 *
029 * @author Antoine Taillefer
030 */
031@XObject("factory")
032public class ActiveFileSystemItemFactoryDescriptor implements Serializable {
033
034    private static final long serialVersionUID = 1630714012089221788L;
035
036    @XNode("")
037    protected String name;
038
039    @XNode("@enabled")
040    protected boolean enabled = true;
041
042    public String getName() {
043        return name;
044    }
045
046    public void setName(String name) {
047        this.name = name;
048    }
049
050    public boolean isEnabled() {
051        return enabled;
052    }
053
054    public void setEnabled(boolean enabled) {
055        this.enabled = enabled;
056    }
057
058    @Override
059    public String toString() {
060        StringBuilder sb = new StringBuilder(name);
061        sb.append(" (enabled = ");
062        sb.append(enabled);
063        sb.append(")");
064        return sb.toString();
065    }
066
067    @Override
068    public boolean equals(Object obj) {
069        if (this == obj) {
070            return true;
071        }
072        if (!(obj instanceof ActiveFileSystemItemFactoryDescriptor)) {
073            return false;
074        }
075        return this.name.equals(((ActiveFileSystemItemFactoryDescriptor) obj).getName());
076    }
077
078    @Override
079    public int hashCode() {
080        return name.hashCode();
081    }
082
083}