Skip to content

Commit

Permalink
qa: Resolve consistency code smells
Browse files Browse the repository at this point in the history
  • Loading branch information
groldan committed Dec 7, 2023
1 parent c6d149f commit 000c1b9
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@
@JsonSubTypes.Type(value = SettingsAdded.class),
})
@SuppressWarnings("serial")
public abstract class ConfigInfoAdded<INFO extends Info> extends InfoAdded<INFO>
public abstract class ConfigInfoAdded<I extends Info> extends InfoAdded<I>
implements ConfigInfoEvent {

protected ConfigInfoAdded() {
// default constructor, needed for deserialization
}

protected ConfigInfoAdded(long updateSequence, INFO object) {
protected ConfigInfoAdded(long updateSequence, I object) {
super(updateSequence, object);
}

Expand All @@ -41,22 +41,18 @@ protected ConfigInfoAdded(long updateSequence, INFO object) {
long updateSequence, @NonNull I info) {

final ConfigInfoType type = ConfigInfoType.valueOf(info);
switch (type) {
case GeoServerInfo:
return (ConfigInfoAdded<I>)
GeoServerInfoSet.createLocal(updateSequence, (GeoServerInfo) info);
case ServiceInfo:
return (ConfigInfoAdded<I>)
ServiceAdded.createLocal(updateSequence, (ServiceInfo) info);
case SettingsInfo:
return (ConfigInfoAdded<I>)
SettingsAdded.createLocal(updateSequence, (SettingsInfo) info);
case LoggingInfo:
return (ConfigInfoAdded<I>)
LoggingInfoSet.createLocal(updateSequence, (LoggingInfo) info);
default:
throw new IllegalArgumentException(
"Uknown or unsupported config Info type: " + type + ". " + info);
}
return (ConfigInfoAdded<I>)
switch (type) {
case GeoServerInfo -> GeoServerInfoSet.createLocal(
updateSequence, (GeoServerInfo) info);
case ServiceInfo -> ServiceAdded.createLocal(
updateSequence, (ServiceInfo) info);
case SettingsInfo -> SettingsAdded.createLocal(
updateSequence, (SettingsInfo) info);
case LoggingInfo -> LoggingInfoSet.createLocal(
updateSequence, (LoggingInfo) info);
default -> throw new IllegalArgumentException(
"Uknown or unsupported config Info type: " + type + ". " + info);
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
@JsonSubTypes.Type(value = SettingsModified.class),
})
@SuppressWarnings("serial")
public abstract class ConfigInfoModified<INFO extends Info> extends InfoModified<INFO>
public abstract class ConfigInfoModified<I extends Info> extends InfoModified<I>
implements ConfigInfoEvent {

protected ConfigInfoModified() {
Expand All @@ -46,27 +46,18 @@ protected ConfigInfoModified(
long updateSequence, @NonNull Info info, @NonNull Patch patch) {

final ConfigInfoType type = ConfigInfoType.valueOf(info);
switch (type) {
case GeoServerInfo:
{
return (ConfigInfoModified<I>)
GeoServerInfoModified.createLocal(
updateSequence, (GeoServerInfo) info, patch);
}
case ServiceInfo:
ServiceInfo service = (ServiceInfo) info;
return (ConfigInfoModified<I>)
ServiceModified.createLocal(updateSequence, service, patch);
case SettingsInfo:
SettingsInfo settings = (SettingsInfo) info;
return (ConfigInfoModified<I>)
SettingsModified.createLocal(updateSequence, settings, patch);
case LoggingInfo:
return (ConfigInfoModified<I>)
LoggingInfoModified.createLocal(updateSequence, (LoggingInfo) info, patch);
default:
throw new IllegalArgumentException(
"Uknown or unsupported config Info type: " + type + ". " + info);
}
return (ConfigInfoModified<I>)
switch (type) {
case GeoServerInfo -> GeoServerInfoModified.createLocal(
updateSequence, (GeoServerInfo) info, patch);
case ServiceInfo -> ServiceModified.createLocal(
updateSequence, (ServiceInfo) info, patch);
case SettingsInfo -> SettingsModified.createLocal(
updateSequence, (SettingsInfo) info, patch);
case LoggingInfo -> LoggingInfoModified.createLocal(
updateSequence, (LoggingInfo) info, patch);
default -> throw new IllegalArgumentException(
"Uknown or unsupported config Info type: " + type + ". " + info);
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,14 @@ protected ConfigInfoRemoved(
long updateSequence, @NonNull I info) {

final ConfigInfoType type = ConfigInfoType.valueOf(info);
return switch (type) {
case ServiceInfo -> (ConfigInfoRemoved<I>)
ServiceRemoved.createLocal(updateSequence, (ServiceInfo) info);
case SettingsInfo -> (ConfigInfoRemoved<I>)
SettingsRemoved.createLocal(updateSequence, (SettingsInfo) info);
default -> throw new IllegalArgumentException(
"Uknown or unsupported config Info type: " + type + ". " + info);
};
return (ConfigInfoRemoved<I>)
switch (type) {
case ServiceInfo -> ServiceRemoved.createLocal(
updateSequence, (ServiceInfo) info);
case SettingsInfo -> SettingsRemoved.createLocal(
updateSequence, (SettingsInfo) info);
default -> throw new IllegalArgumentException(
"Uknown or unsupported config Info type: " + type + ". " + info);
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -409,41 +409,81 @@ public List<StyleInfo> getStylesByWorkspace(WorkspaceInfo workspace) {
return resolveOutbound(super.getStylesByWorkspace(workspace));
}

/**
* @deprecated as per {@link ExtendedCatalogFacade#save(WorkspaceInfo)} use {@link
* #update(CatalogInfo, Patch)} instead
*/
@Deprecated(since = "1.0")
@Override
public void save(WorkspaceInfo info) {
super.save(resolveInbound(info));
}

/**
* @deprecated as per {@link ExtendedCatalogFacade#save(NamespaceInfo)} use {@link
* #update(CatalogInfo, Patch)} instead
*/
@Deprecated(since = "1.0")
@Override
public void save(NamespaceInfo info) {
super.save(resolveInbound(info));
}

/**
* @deprecated as per {@link ExtendedCatalogFacade#save(StoreInfo)} use {@link
* #update(CatalogInfo, Patch)} instead
*/
@Deprecated(since = "1.0")
@Override
public void save(StoreInfo info) {
super.save(resolveInbound(info));
}

/**
* @deprecated as per {@link ExtendedCatalogFacade#save(ResourceInfo)} use {@link
* #update(CatalogInfo, Patch)} instead
*/
@Deprecated(since = "1.0")
@Override
public void save(ResourceInfo info) {
super.save(resolveInbound(info));
}

/**
* @deprecated as per {@link ExtendedCatalogFacade#save(LayerInfo)} use {@link
* #update(CatalogInfo, Patch)} instead
*/
@Deprecated(since = "1.0")
@Override
public void save(LayerInfo info) {
super.save(resolveInbound(info));
}

/**
* @deprecated as per {@link ExtendedCatalogFacade#save(LayerGroupInfo)} use {@link
* #update(CatalogInfo, Patch)} instead
*/
@Deprecated(since = "1.0")
@Override
public void save(LayerGroupInfo info) {
super.save(resolveInbound(info));
}

/**
* @deprecated as per {@link ExtendedCatalogFacade#save(StyleInfo)} use {@link
* #update(CatalogInfo, Patch)} instead
*/
@Deprecated(since = "1.0")
@Override
public void save(StyleInfo info) {
super.save(resolveInbound(info));
}

/**
* @deprecated as per {@link ExtendedCatalogFacade#save(MapInfo)} use {@link
* #update(CatalogInfo, Patch)} instead
*/
@Deprecated(since = "1.0")
@Override
public void save(MapInfo info) {
super.save(resolveInbound(info));
Expand Down Expand Up @@ -489,11 +529,14 @@ public void remove(MapInfo info) {
super.remove(resolveInbound(info));
}

/**
* @deprecated as per {@link ExtendedCatalogFacade#list()} use {@link #query(Query)} instead
*/
@Deprecated(since = "1.0")
@Override
public <T extends CatalogInfo> CloseableIterator<T> list(
Class<T> of, Filter filter, Integer offset, Integer count, SortBy... sortOrder) {

@SuppressWarnings("deprecation")
final CloseableIterator<T> orig = facade().list(of, filter, offset, count, sortOrder);
return CloseableIteratorAdapter.transform(orig, this::resolveOutbound);
}
Expand Down

0 comments on commit 000c1b9

Please sign in to comment.