org.fourthline.cling.model.meta.StateVariableAllowedValueRange Java Examples

The following examples show how to use org.fourthline.cling.model.meta.StateVariableAllowedValueRange. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MutableStateVariable.java    From TVRemoteIME with GNU General Public License v2.0 6 votes vote down vote up
public StateVariable build() {
    return new StateVariable(
            name,
            new StateVariableTypeDetails(
                    dataType,
                    defaultValue,
                    allowedValues == null || allowedValues.size() == 0
                            ? null
                            : allowedValues.toArray(new String[allowedValues.size()]),
                    allowedValueRange == null
                            ? null :
                            new StateVariableAllowedValueRange(
                                    allowedValueRange.minimum,
                                    allowedValueRange.maximum,
                                    allowedValueRange.step
                            )
            ),
            eventDetails
    );
}
 
Example #2
Source File: AnnotationStateVariableBinder.java    From TVRemoteIME with GNU General Public License v2.0 6 votes vote down vote up
protected StateVariableAllowedValueRange getAllowedRangeFromProvider() throws  LocalServiceBindingException {
    Class provider = getAnnotation().allowedValueRangeProvider();
    if (!AllowedValueRangeProvider.class.isAssignableFrom(provider))
        throw new LocalServiceBindingException(
            "Allowed value range provider is not of type " + AllowedValueRangeProvider.class + ": " + getName()
        );
    try {
        AllowedValueRangeProvider providerInstance =
            ((Class<? extends AllowedValueRangeProvider>) provider).newInstance();
        return getAllowedValueRange(
            providerInstance.getMinimum(),
            providerInstance.getMaximum(),
            providerInstance.getStep()
        );
    } catch (Exception ex) {
        throw new LocalServiceBindingException(
            "Allowed value range provider can't be instantiated: " + getName(), ex
        );
    }
}
 
Example #3
Source File: MutableStateVariable.java    From DroidDLNA with GNU General Public License v3.0 6 votes vote down vote up
public StateVariable build() {
    return new StateVariable(
            name,
            new StateVariableTypeDetails(
                    dataType,
                    defaultValue,
                    allowedValues == null || allowedValues.size() == 0
                            ? null
                            : allowedValues.toArray(new String[allowedValues.size()]),
                    allowedValueRange == null
                            ? null :
                            new StateVariableAllowedValueRange(
                                    allowedValueRange.minimum,
                                    allowedValueRange.maximum,
                                    allowedValueRange.step
                            )
            ),
            eventDetails
    );
}
 
Example #4
Source File: AnnotationStateVariableBinder.java    From DroidDLNA with GNU General Public License v3.0 6 votes vote down vote up
protected StateVariableAllowedValueRange getAllowedRangeFromProvider() throws  LocalServiceBindingException {
    Class provider = getAnnotation().allowedValueRangeProvider();
    if (!AllowedValueRangeProvider.class.isAssignableFrom(provider))
        throw new LocalServiceBindingException(
            "Allowed value range provider is not of type " + AllowedValueRangeProvider.class + ": " + getName()
        );
    try {
        AllowedValueRangeProvider providerInstance =
            ((Class<? extends AllowedValueRangeProvider>) provider).newInstance();
        return getAllowedValueRange(
            providerInstance.getMinimum(),
            providerInstance.getMaximum(),
            providerInstance.getStep()
        );
    } catch (Exception ex) {
        throw new LocalServiceBindingException(
            "Allowed value range provider can't be instantiated: " + getName(), ex
        );
    }
}
 
Example #5
Source File: AnnotationStateVariableBinder.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
protected StateVariableAllowedValueRange getAllowedValueRange(long min,
                                                              long max,
                                                              long step) throws LocalServiceBindingException {
    if (max < min) {
        throw new LocalServiceBindingException(
                "Allowed value range maximum is smaller than minimum: " + getName()
        );
    }

    return new StateVariableAllowedValueRange(min, max, step);
}
 
Example #6
Source File: AnnotationStateVariableBinder.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
protected StateVariableAllowedValueRange getAllowedValueRange(long min,
                                                              long max,
                                                              long step) throws LocalServiceBindingException {
    if (max < min) {
        throw new LocalServiceBindingException(
                "Allowed value range maximum is smaller than minimum: " + getName()
        );
    }

    return new StateVariableAllowedValueRange(min, max, step);
}