// Path: Android/FPVR/app/src/main/java/com/solersoft/fpvr/util/TypeUtils.java
// public class TypeUtils
// {
//     public static <T> T as(Class<T> t, Object o)
//     {
//         return t.isAssignableFrom(o.getClass()) ? t.cast(o) : null;
//     }
// }


import com.solersoft.fpvr.util.TypeUtils;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
package com.solersoft.fpvr.fpvrlib;



/**
 * A base class implementation of the {@link IVehicle} interface.
 */
public abstract class Vehicle extends Connectable implements IVehicle
{
    //region Constants
    private static final String TAG = "Vehicle";
    //endregion

    //region Member Variables
    private Collection<IVehicleService> services = new HashSet<IVehicleService>();
    //endregion

    //region Constructors
    /**
     * Initializes a new {@link Vehicle}.
     */
    public Vehicle()
    {
    }
    //endregion

    //region Internal Methods
    protected void connectService(final Iterator<IVehicleService> iterator, final boolean allConnected, final ResultHandler handler)
    {
        if (iterator.hasNext())
        {
            // Get next service
            IVehicleService service = iterator.next();

            // Try to get lifecycle
// Path: Android/FPVR/app/src/main/java/com/solersoft/fpvr/util/TypeUtils.java
// public class TypeUtils
// {
//     public static <T> T as(Class<T> t, Object o)
//     {
//         return t.isAssignableFrom(o.getClass()) ? t.cast(o) : null;
//     }
// }


// Path: Android/FPVR/app/src/main/java/com/solersoft/fpvr/fpvrlib/Vehicle.java
import com.solersoft.fpvr.util.TypeUtils;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;

package com.solersoft.fpvr.fpvrlib;



/**
 * A base class implementation of the {@link IVehicle} interface.
 */
public abstract class Vehicle extends Connectable implements IVehicle
{
    //region Constants
    private static final String TAG = "Vehicle";
    //endregion

    //region Member Variables
    private Collection<IVehicleService> services = new HashSet<IVehicleService>();
    //endregion

    //region Constructors
    /**
     * Initializes a new {@link Vehicle}.
     */
    public Vehicle()
    {
    }
    //endregion

    //region Internal Methods
    protected void connectService(final Iterator<IVehicleService> iterator, final boolean allConnected, final ResultHandler handler)
    {
        if (iterator.hasNext())
        {
            // Get next service
            IVehicleService service = iterator.next();

            // Try to get lifecycle
            IConnectable connectable = TypeUtils.as(IConnectable.class, service);