001/*
002 * (C) Copyright 2006-2011 Nuxeo SA (http://nuxeo.com/) and others.
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-2.1.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 *     Thomas Roger <troger@nuxeo.com>
016 */
017
018package org.nuxeo.ecm.platform.video.service;
019
020import org.nuxeo.common.xmap.annotation.XNode;
021import org.nuxeo.common.xmap.annotation.XObject;
022
023/**
024 * Object representing a registered automatic video conversion on the {@link VideoService}.
025 * <p>
026 * An {@code AutomaticVideoConversion} references the {@code VideoConversion} through its name.
027 *
028 * @author <a href="mailto:troger@nuxeo.com">Thomas Roger</a>
029 * @since 5.5
030 */
031@XObject("automaticVideoConversion")
032public class AutomaticVideoConversion implements Cloneable, Comparable<AutomaticVideoConversion> {
033
034    @XNode("@name")
035    private String name;
036
037    @XNode("@enabled")
038    private boolean enabled = true;
039
040    @XNode("@order")
041    private int order = 0;
042
043    public String getName() {
044        return name;
045    }
046
047    public boolean isEnabled() {
048        return enabled;
049    }
050
051    public void setEnabled(boolean enabled) {
052        this.enabled = enabled;
053    }
054
055    public int getOrder() {
056        return order;
057    }
058
059    @Override
060    public AutomaticVideoConversion clone() throws CloneNotSupportedException {
061        return (AutomaticVideoConversion) super.clone();
062    }
063
064    @Override
065    public int compareTo(AutomaticVideoConversion o) {
066        int cmp = order - o.order;
067        if (cmp == 0) {
068            // make sure we have a deterministic sort
069            cmp = name.compareTo(o.name);
070        }
071        return cmp;
072    }
073
074}