All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.flash3388.flashlib.io.devices.DeviceInterface Maven / Gradle / Ivy

The newest version!
package com.flash3388.flashlib.io.devices;

import com.flash3388.flashlib.annotations.MainThreadOnly;

import java.util.Map;

/**
 * A provider/creator of devices of certain types. Each registered implementation
 * has an identifier to find it.
 *
 * @since FlashLib 3.2.0
 */
public interface DeviceInterface {

    /**
     * Finds a registered implementation for the given ID which matches the wanted type.
     * Once the implementation is found, a constructor is matched to the given arguments
     * count and an instance is created.
     *
     * @param id implementation identifier
     * @param type type which the implementation must support (usually interface)
     * @param namedArgs arguments to the constructor
     * @return created instance
     * @param  type which the implementation must support
     */
    @MainThreadOnly
     T newDevice(int id, Class type, Map namedArgs);

    /**
     * Finds a registered implementation for the given ID which matches the wanted type.
     * Once the implementation is found, a constructor is matched to the given arguments
     * count and an instance is created.
     *
     * @param id implementation identifier
     * @param namedArgs arguments to the constructor
     * @return created instance
     * @param  type which the implementation must support, defined by the ID
     */
    @MainThreadOnly
     T newDevice(DeviceId id, Map namedArgs);

    /**
     * Finds a registered implementation for the given ID which matches the wanted type.
     * Once the implementation is found, a constructor is matched to the given arguments
     * count and an instance is created.
     *
     * @param id implementation identifier
     * @param type type which the implementation must support (usually interface)
     * @param namedArgs arguments to the constructor
     * @return created instance
     * @param  type which the implementation must support, defined by the ID
     */
    @MainThreadOnly
     T2 newDevice(DeviceId id, Class type, Map namedArgs);

    /**
     * Creates a new group of {@link SpeedController} devices, which is encapsulated under a single interface.
     *
     * @return an object encapsulating usage of all the device
     */
    @MainThreadOnly
    GroupBuilder newSpeedControllerGroup();

    /**
     * Creates a new group of {@link Solenoid} devices, which is encapsulated under a single interface.
     *
     * @return an object encapsulating usage of all the device
     */
    @MainThreadOnly
    GroupBuilder newSolenoidGroup();

    /**
     * Creates a new group of {@link DoubleSolenoid} devices, which is encapsulated under a single interface.
     *
     * @return an object encapsulating usage of all the device
     */
    @MainThreadOnly
    GroupBuilder newDoubleSolenoidGroup();
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy