package org.opentrafficsim.base.parameters.constraint;
import java.util.Collection;
import java.util.HashSet;
/**
* Constraint that checks whether a collection of classes is a sub collection of constraint collection.
*
* Copyright (c) 2013-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
* BSD-style license. See OpenTrafficSim License.
*
* @version $Revision$, $LastChangedDate$, by $Author$, initial version 30 jun. 2017
* @author Alexander Verbraeck
* @author Peter Knoppers
* @author Wouter Schakel
* @param class
*/
public final class ClassCollectionConstraint extends SubCollectionConstraint>
{
/**
* @param classes Collection<Class<? extends T>>; acceptable classes
*/
private ClassCollectionConstraint(final Collection> classes)
{
super(classes);
}
/**
* Creates a new instance with given collection.
* @param objs Class<? extends T>...; acceptable classes
* @param type class
* @return new instance with given collection
*/
@SafeVarargs
public static ClassCollectionConstraint newInstance(final Class extends T>... objs)
{
Collection> collection = new HashSet<>();
for (Class extends T> clazz : objs)
{
collection.add(clazz);
}
return new ClassCollectionConstraint<>(collection);
}
/** {@inheritDoc} */
@Override
@SuppressWarnings("checkstyle:designforextension")
public String toString()
{
return "ClassCollectionConstraint [classes=" + this.objects + "]";
}
}