View Javadoc
1   /*
2    * #%L
3    * EUGene :: EUGene
4    * %%
5    * Copyright (C) 2004 - 2010 CodeLutin
6    * %%
7    * This program is free software: you can redistribute it and/or modify
8    * it under the terms of the GNU Lesser General Public License as 
9    * published by the Free Software Foundation, either version 3 of the 
10   * License, or (at your option) any later version.
11   * 
12   * This program is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15   * GNU General Lesser Public License for more details.
16   * 
17   * You should have received a copy of the GNU General Lesser Public 
18   * License along with this program.  If not, see
19   * <http://www.gnu.org/licenses/lgpl-3.0.html>.
20   * #L%
21   */
22  
23  package org.nuiton.eugene.models.object.xml;
24  
25  import com.google.common.collect.ImmutableSet;
26  import org.nuiton.eugene.models.object.ObjectModelEnumeration;
27  import org.nuiton.eugene.models.object.ObjectModelModifier;
28  
29  import java.util.ArrayList;
30  import java.util.Collection;
31  import java.util.Set;
32  
33  /**
34   * ObjectModelEnumerationImpl.
35   *
36   * Created: may 4th 2009
37   *
38   * @author Florian Desbois - desbois@codelutin.com
39   */
40  public class ObjectModelEnumerationImpl extends ObjectModelClassifierImpl implements ObjectModelEnumeration {
41  
42      /**
43       * Collection of references corresponding to literal values
44       */
45      private Collection<ObjectModelImplRef> literalRefs = new ArrayList<>();
46  
47      /**
48       * Add a literal to the ObjectModelEnumeration from Digester
49       *
50       * @param ref corresponding to a Literal value
51       */
52      public void addLiteral(ObjectModelImplRef ref) {
53          literalRefs.add(ref);
54      }
55  
56      private static Set<ObjectModelModifier> authorizedModifiers;
57  
58      @Override
59      protected Set<ObjectModelModifier> getAuthorizedModifiers() {
60          if (authorizedModifiers == null) {
61              // Nothing special ?
62              authorizedModifiers = ImmutableSet.of();
63          }
64          return authorizedModifiers;
65      }
66  
67      @Override
68      public Collection<String> getLiterals() {
69          Collection<String> results = new ArrayList<>();
70          for (ObjectModelImplRef ref : literalRefs) {
71              results.add(ref.getName());
72          }
73          return results;
74      }
75  
76  }