Skip to content

Commit

Permalink
Move getSupportedChannelTypeUIDs and getSupportedItemTypesOfChannel t…
Browse files Browse the repository at this point in the history
…o the ProfileType interface so that StateProfileType and TriggerProfileType can both take the three filter lists given by ProfileTypeBuilder

Fixes #4293

Signed-off-by: Olivier Sannier <[email protected]> (github: obones)
  • Loading branch information
obones committed Jul 22, 2024
1 parent 0a5886c commit be1c40a
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.core.thing.profiles.ProfileTypeUID;
import org.openhab.core.thing.profiles.StateProfileType;
import org.openhab.core.thing.type.ChannelTypeUID;

/**
* Default implementation of a {@link StateProfileType}.
Expand All @@ -31,20 +32,27 @@ public class StateProfileTypeImpl implements StateProfileType {
private final String label;
private final Collection<String> supportedItemTypes;
private final Collection<String> supportedItemTypesOfChannel;
private final Collection<ChannelTypeUID> supportedChannelTypeUIDs;

public StateProfileTypeImpl(ProfileTypeUID profileTypeUID, String label, Collection<String> supportedItemTypes,
Collection<String> supportedItemTypesOfChannel) {
Collection<String> supportedItemTypesOfChannel, Collection<ChannelTypeUID> supportedChannelTypeUIDs) {
this.profileTypeUID = profileTypeUID;
this.label = label;
this.supportedItemTypes = Collections.unmodifiableCollection(supportedItemTypes);
this.supportedItemTypesOfChannel = Collections.unmodifiableCollection(supportedItemTypesOfChannel);
this.supportedChannelTypeUIDs = Collections.unmodifiableCollection(supportedChannelTypeUIDs);
}

@Override
public ProfileTypeUID getUID() {
return profileTypeUID;
}

@Override
public Collection<ChannelTypeUID> getSupportedChannelTypeUIDs() {
return supportedChannelTypeUIDs;
}

@Override
public Collection<String> getSupportedItemTypes() {
return supportedItemTypes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@ public class TriggerProfileTypeImpl implements TriggerProfileType {
private final ProfileTypeUID profileTypeUID;
private final String label;
private final Collection<String> supportedItemTypes;
private final Collection<String> supportedItemTypesOfChannel;
private final Collection<ChannelTypeUID> supportedChannelTypeUIDs;

public TriggerProfileTypeImpl(ProfileTypeUID profileTypeUID, String label, Collection<String> supportedItemTypes,
Collection<ChannelTypeUID> supportedChannelTypeUIDs) {
Collection<String> supportedItemTypesOfChannel, Collection<ChannelTypeUID> supportedChannelTypeUIDs) {
this.profileTypeUID = profileTypeUID;
this.label = label;
this.supportedItemTypes = Collections.unmodifiableCollection(supportedItemTypes);
this.supportedItemTypesOfChannel = Collections.unmodifiableCollection(supportedItemTypesOfChannel);
this.supportedChannelTypeUIDs = Collections.unmodifiableCollection(supportedChannelTypeUIDs);
}

Expand All @@ -60,4 +62,9 @@ public String getLabel() {
public ProfileTypeUID getUID() {
return profileTypeUID;
}

@Override
public Collection<String> getSupportedItemTypesOfChannel() {
return supportedItemTypesOfChannel;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.core.common.registry.Identifiable;
import org.openhab.core.thing.type.ChannelTypeUID;

/**
* Describes a profile type.
Expand All @@ -31,6 +32,19 @@ public interface ProfileType extends Identifiable<ProfileTypeUID> {
*/
Collection<String> getSupportedItemTypes();

/**
* Get a collection of ItemType names that a Channel needs to support in order to able to use this ProfileType
*
* @return a collection of supported ItemType names (an empty list means ALL types are supported)
*/
Collection<String> getSupportedItemTypesOfChannel();

/**
*
* @return a collection of ChannelTypeUIDs (may be empty if all are supported).
*/
Collection<ChannelTypeUID> getSupportedChannelTypeUIDs();

/**
* Get a human readable description.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public static ProfileTypeBuilder<StateProfileType> newState(ProfileTypeUID profi
return new ProfileTypeBuilder<>(profileTypeUID, label,
(leProfileTypeUID, leLabel, leSupportedItemTypes, leSupportedItemTypesOfChannel,
leSupportedChannelTypeUIDs) -> new StateProfileTypeImpl(leProfileTypeUID, leLabel,
leSupportedItemTypes, leSupportedItemTypesOfChannel));
leSupportedItemTypes, leSupportedItemTypesOfChannel, leSupportedChannelTypeUIDs));
}

/**
Expand All @@ -78,7 +78,7 @@ public static ProfileTypeBuilder<TriggerProfileType> newTrigger(ProfileTypeUID p
return new ProfileTypeBuilder<>(profileTypeUID, label,
(leProfileTypeUID, leLabel, leSupportedItemTypes, leSupportedItemTypesOfChannel,
leSupportedChannelTypeUIDs) -> new TriggerProfileTypeImpl(leProfileTypeUID, leLabel,
leSupportedItemTypes, leSupportedChannelTypeUIDs));
leSupportedItemTypes, leSupportedItemTypesOfChannel, leSupportedChannelTypeUIDs));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
*/
package org.openhab.core.thing.profiles;

import java.util.Collection;

import org.eclipse.jdt.annotation.NonNullByDefault;

/**
Expand All @@ -24,11 +22,4 @@
*/
@NonNullByDefault
public interface StateProfileType extends ProfileType {

/**
* Get a collection of ItemType names that a Channel needs to support in order to able to use this ProfileType
*
* @return a collection of supported ItemType names (an empty list means ALL types are supported)
*/
Collection<String> getSupportedItemTypesOfChannel();
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@
*/
package org.openhab.core.thing.profiles;

import java.util.Collection;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.core.thing.type.ChannelTypeUID;

/**
* Describes a {@link TriggerProfile} type.
Expand All @@ -24,10 +21,4 @@
*/
@NonNullByDefault
public interface TriggerProfileType extends ProfileType {

/**
*
* @return a collection of ChannelTypeUIDs (may be empty if all are supported).
*/
Collection<ChannelTypeUID> getSupportedChannelTypeUIDs();
}

0 comments on commit be1c40a

Please sign in to comment.