-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17865 from phillip-kruger/platform-model-enhancement
Make the platform model easier to navigate
- Loading branch information
Showing
7 changed files
with
100 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 6 additions & 6 deletions
12
...ects/tools/registry-client/src/main/java/io/quarkus/registry/catalog/PlatformCatalog.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
package io.quarkus.registry.catalog; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnore; | ||
import java.util.List; | ||
import java.util.Collection; | ||
import java.util.Map; | ||
|
||
public interface PlatformCatalog { | ||
|
||
List<Platform> getPlatforms(); | ||
Collection<Platform> getPlatforms(); | ||
|
||
Map<String, Object> getMetadata(); | ||
|
||
@JsonIgnore | ||
Platform getPlatform(String platformId); | ||
|
||
default Platform getRecommendedPlatform() { | ||
final List<Platform> platforms = getPlatforms(); | ||
return platforms.isEmpty() ? null : platforms.get(0); | ||
final Collection<Platform> platforms = getPlatforms(); | ||
return platforms.isEmpty() ? null : platforms.iterator().next(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 21 additions & 7 deletions
28
...s/registry-client/src/main/java/io/quarkus/registry/catalog/json/JsonPlatformCatalog.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,46 @@ | ||
package io.quarkus.registry.catalog.json; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnore; | ||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize; | ||
import io.quarkus.registry.catalog.Platform; | ||
import io.quarkus.registry.catalog.PlatformCatalog; | ||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.Collections; | ||
import java.util.LinkedHashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
@JsonInclude(JsonInclude.Include.NON_EMPTY) | ||
@JsonIgnoreProperties(value = { "recommendedPlatform" }) | ||
public class JsonPlatformCatalog extends JsonEntityWithAnySupport implements PlatformCatalog { | ||
|
||
private List<Platform> platforms; | ||
private Map<String, Platform> platforms; | ||
|
||
@Override | ||
@JsonDeserialize(contentAs = JsonPlatform.class) | ||
public List<Platform> getPlatforms() { | ||
return platforms == null ? Collections.emptyList() : platforms; | ||
public Collection<Platform> getPlatforms() { | ||
return platforms == null ? Collections.emptyList() : platforms.values(); | ||
} | ||
|
||
@Override | ||
@JsonIgnore | ||
public Platform getPlatform(String platformId) { | ||
return platforms == null ? null : platforms.get(platformId); | ||
} | ||
|
||
public void setPlatforms(List<Platform> platforms) { | ||
this.platforms = platforms; | ||
for (Platform p : platforms) { | ||
addPlatform(p); | ||
} | ||
} | ||
|
||
public void addPlatform(Platform platform) { | ||
if (platforms == null) { | ||
platforms = new ArrayList<>(); | ||
platforms = new LinkedHashMap<>(); | ||
} | ||
platforms.add(platform); | ||
platforms.put(platform.getPlatformKey(), platform); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters