001/*
002 *  Copyright 2025 Anyware Services
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 */
016package org.ametys.runtime.model.disableconditions;
017
018import java.util.UUID;
019
020import org.ametys.runtime.model.DefinitionContext;
021import org.ametys.runtime.model.Model;
022import org.ametys.runtime.model.ModelItem;
023
024/**
025 * External implementation for {@link DisableCondition}
026 */
027public abstract class AbstractExternalDisableCondition implements DisableCondition
028{
029    /** the condition identifier */
030    protected String _id;
031    
032    /**
033     * Creates an external disable condition
034     */
035    public AbstractExternalDisableCondition()
036    {
037        _id = UUID.randomUUID().toString();
038    }
039    
040    public void init(Model model, ModelItem definition) throws Exception
041    {
042        // Do nothing
043    }
044    
045    public String getId()
046    {
047        return _id;
048    }
049    
050    public String getName()
051    {
052        return getClass().getName();
053    }
054    
055    public OPERATOR getOperator()
056    {
057        return OPERATOR.EQ;
058    }
059    
060    public String getValue()
061    {
062        return String.valueOf(Boolean.TRUE);
063    }
064    
065    public boolean isExternal(DefinitionContext context)
066    {
067        return true;
068    }
069}