001/*
002 * (C) Copyright 2014 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-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 *     Thierry Delprat
016 */
017package org.nuxeo.ecm.core.uidgen;
018
019import org.nuxeo.common.xmap.annotation.XNode;
020import org.nuxeo.common.xmap.annotation.XObject;
021import org.nuxeo.ecm.core.uidgen.UIDSequencer;
022
023/**
024 * @since 7.3
025 */
026@XObject("sequencer")
027public class UIDSequencerProviderDescriptor {
028
029    @XNode("@name")
030    protected String name;
031
032    @XNode("@default")
033    protected boolean isdefault;
034
035    @XNode("@class")
036    protected Class<? extends UIDSequencer> sequencerClass;
037
038    public UIDSequencer getSequencer() throws Exception {
039
040        if (sequencerClass != null) {
041            return sequencerClass.newInstance();
042        }
043
044        return null;
045    }
046
047    public String getName() {
048        if (name == null && sequencerClass != null) {
049            name = sequencerClass.getSimpleName();
050        }
051        return name;
052    }
053
054    public boolean isIsdefault() {
055        return isdefault;
056    }
057
058}