001/*
002 * Copyright 2023 the original author or authors.
003 * <p>
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 * <p>
008 * https://www.apache.org/licenses/LICENSE-2.0
009 * <p>
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 de.cuioss.test.generator.impl;
017
018import java.net.MalformedURLException;
019import java.net.URL;
020
021import de.cuioss.test.generator.Generators;
022import de.cuioss.test.generator.TypedGenerator;
023
024/**
025 * {@link TypedGenerator} for generating basic {@link URL}s
026 *
027 * @author Oliver Wolff
028 */
029public class URLGenerator implements TypedGenerator<URL> {
030
031    private static final TypedGenerator<String> generator = Generators.fixedValues(String.class, "https://www.heise.de",
032            "https://stackoverflow.com", "https://github.com/cuioss", "https://www.gitlab.com", "https://sonarcloud.io",
033            "https://www.eclipse.org", "https://www.sesamestreet.org/", "https://de.wikipedia.org",
034            "https://www.xing.com", "https://www.mozilla.org", "https://avm.de/", "https://www.primefaces.org/",
035            "http://getbootstrap.com", "https://x-tention.com", "https://www.microsoft.com", "https://www.apple.com",
036            "https://www.android.com");
037
038    @Override
039    public URL next() {
040        try {
041            return new URL(generator.next());
042        } catch (final MalformedURLException e) {
043            throw new IllegalStateException(e);
044        }
045    }
046
047    @Override
048    public Class<URL> getType() {
049        return URL.class;
050    }
051
052}