001/* Copyright (C) 2013 TU Dortmund
002 * This file is part of AutomataLib, http://www.automatalib.net/.
003 * 
004 * AutomataLib is free software; you can redistribute it and/or
005 * modify it under the terms of the GNU Lesser General Public
006 * License version 3.0 as published by the Free Software Foundation.
007 * 
008 * AutomataLib is distributed in the hope that it will be useful,
009 * but WITHOUT ANY WARRANTY; without even the implied warranty of
010 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
011 * Lesser General Public License for more details.
012 * 
013 * You should have received a copy of the GNU Lesser General Public
014 * License along with AutomataLib; if not, see
015 * http://www.gnu.de/documents/lgpl.en.html.
016 */
017package net.automatalib.words.impl;
018
019import java.util.List;
020
021import net.automatalib.commons.util.collections.CollectionsUtil;
022import net.automatalib.words.Alphabet;
023
024public abstract class Alphabets {
025
026        public static <T> Alphabet<T> fromList(List<? extends T> list) {
027                return new ListAlphabet<>(list);
028        }
029        
030        @SafeVarargs
031        public static <T> Alphabet<T> fromArray(T ...symbols) {
032                return new ArrayAlphabet<>(symbols);
033        }
034        
035        public static <E extends Enum<E>> Alphabet<E> fromEnum(Class<E> enumClazz, boolean withNull) {
036                return new EnumAlphabet<>(enumClazz, withNull);
037        }
038        
039        public static <E extends Enum<E>> Alphabet<E> fromEnum(Class<E> enumClazz) {
040                return fromEnum(enumClazz, false);
041        }
042        
043        public static Alphabet<Integer> integers(int startInclusive, int endInclusive) {
044                List<Integer> lst = CollectionsUtil.intRange(startInclusive, endInclusive + 1);
045                return fromList(lst);
046        }
047        
048        public static Alphabet<Character> characters(char startInclusive, char endInclusive) {
049                List<Character> lst = CollectionsUtil.charRange(startInclusive, (char)(endInclusive + 1));
050                return fromList(lst);
051        }
052        
053        
054        
055        private Alphabets() {
056                // prevent inheritance
057        }
058
059}