Class SubCollectionConstraint<T>

java.lang.Object
org.opentrafficsim.base.parameters.constraint.SubCollectionConstraint<T>
Type Parameters:
T - object type
All Implemented Interfaces:
Constraint<java.util.Collection<T>>
Direct Known Subclasses:
ClassCollectionConstraint

public class SubCollectionConstraint<T>
extends java.lang.Object
implements Constraint<java.util.Collection<T>>
Constraint that checks whether a collection (the parameter value) is a subset of a 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 10 sep. 2017
Author:
Alexander Verbraeck, Peter Knoppers, Wouter Schakel
  • Field Summary

    Fields 
    Modifier and Type Field Description
    protected java.util.Collection<T> objects
    Acceptable objects.
  • Constructor Summary

    Constructors 
    Constructor Description
    SubCollectionConstraint​(java.util.Collection<T> objects)  
  • Method Summary

    Modifier and Type Method Description
    boolean accept​(java.util.Collection<T> value)
    Checks whether the value complies with constraints.
    java.lang.String failMessage()
    Returns a message for value failure, pointing to a parameter using '%s'.
    static <T> SubCollectionConstraint<T> newInstance​(T... objs)
    Creates a new instance with given collection.
    java.lang.String toString()

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • objects

      protected final java.util.Collection<T> objects
      Acceptable objects.
  • Constructor Details

    • SubCollectionConstraint

      public SubCollectionConstraint​(java.util.Collection<T> objects)
      Parameters:
      objects - Collection<T>; acceptable objects
  • Method Details

    • accept

      public boolean accept​(java.util.Collection<T> value)
      Checks whether the value complies with constraints.
      Specified by:
      accept in interface Constraint<T>
      Parameters:
      value - T; Value to check.
      Returns:
      Whether the value complies with constraints.
    • failMessage

      public java.lang.String failMessage()
      Returns a message for value failure, pointing to a parameter using '%s'.
      Specified by:
      failMessage in interface Constraint<T>
      Returns:
      Message for value failure, pointing to a parameter using '%s'.
    • newInstance

      @SafeVarargs public static <T> SubCollectionConstraint<T> newInstance​(T... objs)
      Creates a new instance with given collection.
      Type Parameters:
      T - type
      Parameters:
      objs - T...; acceptable objects
      Returns:
      new instance with given collection
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object