Class ParseUtil


  • public final class ParseUtil
    extends Object
    Parser - Utility class for parsing using JAXB generated classes.

    Copyright (c) 2003-2020 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. BSD-style license. See OpenTrafficSim License.

    Author:
    Alexander Verbraeck
    • Method Detail

      • getObjectsOfType

        public static <T> List<T> getObjectsOfType​(List<?> objectList,
                                                   Class<T> clazz)
        Returns all objects of given type from the list of all objects.
        Type Parameters:
        T - type
        Parameters:
        objectList - List<?>; list of objects
        clazz - Class<T>; class of type of objects to return
        Returns:
        list of all objects of given type from the list of all objects
      • findObject

        public static <T> T findObject​(List<?> objectList,
                                       Class<T> clazz,
                                       Predicate<T> predicate)
        Select object of given type by predicate.
        Type Parameters:
        T - type
        Parameters:
        objectList - List<?>; list of objects
        clazz - Class<T>; class of type of objects to return
        predicate - Predicate<T>; predicate
        Returns:
        (first) object of given type that matches the predicate
      • findObject

        public static <T> T findObject​(List<T> objectList,
                                       Predicate<T> predicate)
        Select object of given type by predicate.
        Type Parameters:
        T - type
        Parameters:
        objectList - List<T>; list of objects
        predicate - Predicate<T>; predicate
        Returns:
        (first) object of given type that matches the predicate