Skip to content

Commit

Permalink
Use 'uid' instead of 'UID' as method parameters (#3840)
Browse files Browse the repository at this point in the history
Using 'UID' is confusing as method parameter because it can be mistaken for some kind of constant while reading code.

Signed-off-by: Wouter Born <github@maindrain.net>
  • Loading branch information
wborn authored Oct 9, 2023
1 parent e8e1c9f commit 783c57c
Show file tree
Hide file tree
Showing 26 changed files with 65 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ public MediaActionTypeProvider(final @Reference AudioManager audioManager) {

@SuppressWarnings("unchecked")
@Override
public @Nullable ModuleType getModuleType(String UID, @Nullable Locale locale) {
switch (UID) {
public @Nullable ModuleType getModuleType(String uid, @Nullable Locale locale) {
switch (uid) {
case PlayActionHandler.TYPE_ID:
return getPlayActionType(locale);
case SayActionHandler.TYPE_ID:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ public void removeProviderChangeListener(ProviderChangeListener<ModuleType> list

@SuppressWarnings("unchecked")
@Override
public <T extends ModuleType> T getModuleType(String UID, @Nullable Locale locale) {
return (T) modulesTypes.get(UID);
public <T extends ModuleType> T getModuleType(String uid, @Nullable Locale locale) {
return (T) modulesTypes.get(uid);
}

@SuppressWarnings("unchecked")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ public ScriptedAutomationManager(RuleSupportRuleRegistryDelegate ruleRegistryDel
this.scriptedPrivateModuleHandlerFactory = scriptedPrivateModuleHandlerFactory;
}

public void removeModuleType(String UID) {
if (modules.remove(UID)) {
scriptedCustomModuleTypeProvider.removeModuleType(UID);
removeHandler(UID);
public void removeModuleType(String uid) {
if (modules.remove(uid)) {
scriptedCustomModuleTypeProvider.removeModuleType(uid);
removeHandler(uid);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ public void deactivate() {

@SuppressWarnings("unchecked")
@Override
public @Nullable ModuleType getModuleType(String UID, @Nullable Locale locale) {
public @Nullable ModuleType getModuleType(String uid, @Nullable Locale locale) {
if (parameterOptions.isEmpty()) {
return null;
} else if (ScriptActionHandler.TYPE_ID.equals(UID)) {
} else if (ScriptActionHandler.TYPE_ID.equals(uid)) {
return getScriptActionType(locale);
} else if (ScriptConditionHandler.TYPE_ID.equals(UID)) {
} else if (ScriptConditionHandler.TYPE_ID.equals(uid)) {
return getScriptConditionType(locale);
} else {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@ public class ActionImpl extends ModuleImpl implements Action {
/**
* Constructor of Action object.
*
* @param UID action unique id.
* @param uid action unique id.
* @param typeUID module type unique id.
* @param configuration map of configuration values.
* @param label the label
* @param description description
* @param inputs set of connections to other modules (triggers and other actions).
*/
public ActionImpl(String UID, String typeUID, @Nullable Configuration configuration, @Nullable String label,
public ActionImpl(String uid, String typeUID, @Nullable Configuration configuration, @Nullable String label,
@Nullable String description, @Nullable Map<String, String> inputs) {
super(UID, typeUID, configuration, label, description);
super(uid, typeUID, configuration, label, description);
this.inputs = inputs == null ? Map.of() : Map.copyOf(inputs);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,9 @@ public Set<ModuleType> importModuleTypes(String parserType, URL url) throws IOEx

@SuppressWarnings("unchecked")
@Override
public @Nullable ModuleType getModuleType(String UID, @Nullable Locale locale) {
public @Nullable ModuleType getModuleType(String uid, @Nullable Locale locale) {
synchronized (providedObjectsHolder) {
return providedObjectsHolder.get(UID);
return providedObjectsHolder.get(uid);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ public Set<RuleTemplate> importTemplates(String parserType, URL url) throws IOEx
}

@Override
public @Nullable RuleTemplate getTemplate(String UID, @Nullable Locale locale) {
public @Nullable RuleTemplate getTemplate(String uid, @Nullable Locale locale) {
synchronized (providerPortfolio) {
return providedObjectsHolder.get(UID);
return providedObjectsHolder.get(uid);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ public Collection<ModuleType> getAll() {

@SuppressWarnings("unchecked")
@Override
public <T extends ModuleType> T getModuleType(String UID, @Nullable Locale locale) {
return (T) localizeModuleType(UID, locale);
public <T extends ModuleType> T getModuleType(String uid, @Nullable Locale locale) {
return (T) localizeModuleType(uid, locale);
}

@SuppressWarnings("unchecked")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ public void removeProviderChangeListener(ProviderChangeListener<ModuleType> list

@SuppressWarnings("unchecked")
@Override
public <T extends ModuleType> T getModuleType(String UID, @Nullable Locale locale) {
return (T) getPerLocale(providedObjectsHolder.get(UID), locale);
public <T extends ModuleType> T getModuleType(String uid, @Nullable Locale locale) {
return (T) getPerLocale(providedObjectsHolder.get(uid), locale);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ public void removeProviderChangeListener(ProviderChangeListener<RuleTemplate> li
* @see TemplateProvider#getTemplate(java.lang.String, java.util.Locale)
*/
@Override
public @Nullable RuleTemplate getTemplate(String UID, @Nullable Locale locale) {
return getPerLocale(providedObjectsHolder.get(UID), locale);
public @Nullable RuleTemplate getTemplate(String uid, @Nullable Locale locale) {
return getPerLocale(providedObjectsHolder.get(uid), locale);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ public Collection<ModuleType> getAll() {

@SuppressWarnings("unchecked")
@Override
public <T extends ModuleType> @Nullable T getModuleType(String UID, @Nullable Locale locale) {
return (T) providedObjectsHolder.get(UID);
public <T extends ModuleType> @Nullable T getModuleType(String uid, @Nullable Locale locale) {
return (T) providedObjectsHolder.get(uid);
}

@SuppressWarnings("unchecked")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ public Collection<RuleTemplate> getAll() {
}

@Override
public @Nullable RuleTemplate getTemplate(String UID, @Nullable Locale locale) {
return providedObjectsHolder.get(UID);
public @Nullable RuleTemplate getTemplate(String uid, @Nullable Locale locale) {
return providedObjectsHolder.get(uid);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ private List<Output> getOutputsFromMethod(Method method) {
return outputs;
}

public @Nullable ActionType buildModuleType(String UID, Map<String, Set<ModuleInformation>> moduleInformation) {
Set<ModuleInformation> mis = moduleInformation.get(UID);
public @Nullable ActionType buildModuleType(String uid, Map<String, Set<ModuleInformation>> moduleInformation) {
Set<ModuleInformation> mis = moduleInformation.get(uid);
List<ConfigDescriptionParameter> configDescriptions = new ArrayList<>();

if (mis != null && !mis.isEmpty()) {
Expand All @@ -158,7 +158,7 @@ private List<Output> getOutputsFromMethod(Method method) {
if (mi.getConfigName() != null && mi.getThingUID() != null) {
logger.error(
"ModuleType with UID {} has thingUID ({}) and multi-service ({}) property set, ignoring it.",
UID, mi.getConfigName(), mi.getThingUID());
uid, mi.getConfigName(), mi.getThingUID());
return null;
} else if (mi.getConfigName() != null) {
kind = ActionModuleKind.SERVICE;
Expand All @@ -170,7 +170,7 @@ private List<Output> getOutputsFromMethod(Method method) {
if (configParam != null) {
configDescriptions.add(configParam);
}
return new ActionType(UID, configDescriptions, mi.getLabel(), mi.getDescription(), mi.getTags(),
return new ActionType(uid, configDescriptions, mi.getLabel(), mi.getDescription(), mi.getTags(),
mi.getVisibility(), mi.getInputs(), mi.getOutputs());
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,11 @@ public class RuleTemplate implements Template {
* @param configDescriptions describing meta-data for the configuration of the future {@link Rule} instances.
* @param visibility the {@link RuleTemplate}'s visibility.
*/
public RuleTemplate(@Nullable String UID, @Nullable String label, @Nullable String description,
public RuleTemplate(@Nullable String uid, @Nullable String label, @Nullable String description,
@Nullable Set<String> tags, @Nullable List<Trigger> triggers, @Nullable List<Condition> conditions,
@Nullable List<Action> actions, @Nullable List<ConfigDescriptionParameter> configDescriptions,
@Nullable Visibility visibility) {
this.uid = UID == null ? UUID.randomUUID().toString() : UID;
this.uid = uid == null ? UUID.randomUUID().toString() : uid;
this.label = label;
this.description = description;
this.triggers = triggers == null ? List.of() : Collections.unmodifiableList(triggers);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ public interface TemplateProvider<E extends Template> extends Provider<E> {
* Gets the localized Templates defined by this provider. When the localization is not specified or it is not
* supported a Template localized with default locale is returned.
*
* @param UID unique identifier of the desired Template.
* @param uid unique identifier of the desired Template.
* @param locale specifies the desired {@link Locale} to be used for localization of the returned element. If
* localization resources for this locale are not available or the passed locale is {@code null} the
* element is returned with the default localization.
* @return the desired localized Template.
*/
@Nullable
E getTemplate(String UID, @Nullable Locale locale);
E getTemplate(String uid, @Nullable Locale locale);

/**
* Gets the localized Templates defined by this provider. When localization is not specified or it is not supported
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ public Collection<ModuleType> getAll() {

@SuppressWarnings("unchecked")
@Override
public <T extends ModuleType> T getModuleType(String UID, @Nullable Locale locale) {
return (T) localizeModuleType(UID, locale);
public <T extends ModuleType> T getModuleType(String uid, @Nullable Locale locale) {
return (T) localizeModuleType(uid, locale);
}

@SuppressWarnings("unchecked")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,32 +52,32 @@ public class ActionType extends ModuleType {
* Creates an instance of {@link ActionType} with base properties - UID, a {@link List} of configuration
* descriptions and a {@link List} of {@link Input} definitions.
*
* @param UID the {@link ActionType}'s identifier, or {@code null} if a random identifier should be
* @param uid the {@link ActionType}'s identifier, or {@code null} if a random identifier should be
* generated.
* @param configDescriptions describing meta-data for the configuration of the future {@link Action} instances.
* @param inputs a {@link List} with {@link Input} meta-information descriptions of the future
* {@link Action} instances.
*/
public ActionType(@Nullable String UID, @Nullable List<ConfigDescriptionParameter> configDescriptions,
public ActionType(@Nullable String uid, @Nullable List<ConfigDescriptionParameter> configDescriptions,
@Nullable List<Input> inputs) {
this(UID, configDescriptions, inputs, null);
this(uid, configDescriptions, inputs, null);
}

/**
* Creates an instance of the {@link ActionType} with UID, a {@link List} of configuration descriptions,
* a {@link List} of {@link Input} definitions and a {@link List} of {@link Output} descriptions.
*
* @param UID the {@link ActionType}'s identifier, or {@code null} if a random identifier should be
* @param uid the {@link ActionType}'s identifier, or {@code null} if a random identifier should be
* generated.
* @param configDescriptions describing meta-data for the configuration of the future {@link Action} instances.
* @param inputs a {@link List} with {@link Input} meta-information descriptions of the future
* {@link Action} instances.
* @param outputs a {@link List} with {@link Output} meta-information descriptions of the future
* {@link Action} instances.
*/
public ActionType(@Nullable String UID, @Nullable List<ConfigDescriptionParameter> configDescriptions,
public ActionType(@Nullable String uid, @Nullable List<ConfigDescriptionParameter> configDescriptions,
@Nullable List<Input> inputs, @Nullable List<Output> outputs) {
this(UID, configDescriptions, null, null, null, null, inputs, outputs);
this(uid, configDescriptions, null, null, null, null, inputs, outputs);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public CompositeTriggerType(@Nullable String uid, @Nullable List<ConfigDescripti
* Creates an instance of {@code CompositeTriggerType} with ordered set of {@link Trigger} modules. It initializes
* all properties of the {@code CompositeTriggerType}.
*
* @param UID the {@link TriggerType}'s identifier, or {@code null} if a random identifier should be
* @param uid the {@link TriggerType}'s identifier, or {@code null} if a random identifier should be
* generated.
* @param configDescriptions describing meta-data for the configuration of the future {@link Trigger} instances.
* @param label a short and accurate, human-readable label of the {@link TriggerType}.
Expand All @@ -71,10 +71,10 @@ public CompositeTriggerType(@Nullable String uid, @Nullable List<ConfigDescripti
* {@link Trigger} instances.
* @param children is a {@link List} of {@link Trigger} modules.
*/
public CompositeTriggerType(@Nullable String UID, @Nullable List<ConfigDescriptionParameter> configDescriptions,
public CompositeTriggerType(@Nullable String uid, @Nullable List<ConfigDescriptionParameter> configDescriptions,
@Nullable String label, @Nullable String description, @Nullable Set<String> tags,
@Nullable Visibility visibility, @Nullable List<Output> outputs, @Nullable List<Trigger> children) {
super(UID, configDescriptions, label, description, tags, visibility, outputs);
super(uid, configDescriptions, label, description, tags, visibility, outputs);
this.children = children != null ? Collections.unmodifiableList(children) : List.of();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ public interface ModuleTypeProvider extends Provider<ModuleType> {
* Gets the localized {@link ModuleType} defined by this provider. When the localization is not specified
* or it is not supported a {@link ModuleType} with default locale is returned.
*
* @param UID unique identifier of the {@link ModuleType}.
* @param uid unique identifier of the {@link ModuleType}.
* @param locale defines localization of label and description of the {@link ModuleType} or null.
* @param <T> the type of the required object.
* @return localized module type.
*/
<T extends ModuleType> @Nullable T getModuleType(String UID, @Nullable Locale locale);
<T extends ModuleType> @Nullable T getModuleType(String uid, @Nullable Locale locale);

/**
* Gets the localized {@link ModuleType}s defined by this provider. When localization is not specified or
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ public abstract class AbstractThingDTO {
public AbstractThingDTO() {
}

protected AbstractThingDTO(String thingTypeUID, String UID, String label, String bridgeUID,
protected AbstractThingDTO(String thingTypeUID, String uid, String label, String bridgeUID,
Map<String, Object> configuration, Map<String, String> properties, String location) {
this.thingTypeUID = thingTypeUID;
this.UID = UID;
this.UID = uid;
this.label = label;
this.bridgeUID = bridgeUID;
this.configuration = configuration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ public class ChannelTypeDTO {
public ChannelTypeDTO() {
}

public ChannelTypeDTO(String UID, String label, String description, String category, String itemType,
public ChannelTypeDTO(String uid, String label, String description, String category, String itemType,
ChannelKind kind, List<ConfigDescriptionParameterDTO> parameters,
List<ConfigDescriptionParameterGroupDTO> parameterGroups, StateDescription stateDescription,
Set<String> tags, boolean advanced, CommandDescription commandDescription) {
this.UID = UID;
this.UID = uid;
this.label = label;
this.description = description;
this.category = category;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ public class StrippedThingTypeDTO {
public StrippedThingTypeDTO() {
}

public StrippedThingTypeDTO(String UID, String label, String description, String category, boolean listed,
public StrippedThingTypeDTO(String uid, String label, String description, String category, boolean listed,
List<String> supportedBridgeTypeUIDs, boolean bridge) {
this.UID = UID;
this.UID = uid;
this.label = label;
this.description = description;
this.category = category;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ public class ThingDTO extends AbstractThingDTO {
public ThingDTO() {
}

protected ThingDTO(String thingTypeUID, String UID, String label, String bridgeUID, List<ChannelDTO> channels,
protected ThingDTO(String thingTypeUID, String uid, String label, String bridgeUID, List<ChannelDTO> channels,
Map<String, Object> configuration, Map<String, String> properties, String location) {
super(thingTypeUID, UID, label, bridgeUID, configuration, properties, location);
super(thingTypeUID, uid, label, bridgeUID, configuration, properties, location);
this.channels = channels;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ public class ThingTypeDTO extends StrippedThingTypeDTO {
public ThingTypeDTO() {
}

public ThingTypeDTO(String UID, String label, String description, String category, boolean listed,
public ThingTypeDTO(String uid, String label, String description, String category, boolean listed,
List<ConfigDescriptionParameterDTO> configParameters, List<ChannelDefinitionDTO> channels,
List<ChannelGroupDefinitionDTO> channelGroups, List<String> supportedBridgeTypeUIDs,
Map<String, String> properties, boolean bridge, List<ConfigDescriptionParameterGroupDTO> parameterGroups,
List<String> extensibleChannelTypeIds) {
this.UID = UID;
this.UID = uid;
this.label = label;
this.description = description;
this.category = category;
Expand Down
Loading

0 comments on commit 783c57c

Please sign in to comment.