How to Retrieve Type and Locations from CatalogObject After Upgrading Square Java SDK to v44.2.0

Hi Square Team,

I am preparing to upgrade the Square Java SDK from version 40.1.0.20240604 to 44.2.0.20250521.

After upgrading, I’ve noticed that I can no longer use the previous methods to retrieve properties from CatalogObject, such as:

  • type
  • presentAtAllLocations
  • presentAtLocationIds
  • absentAtLocationIds

40.1.0.20240604

@JsonCreator
    public CatalogObject(
            @JsonProperty("type") String type,
            @JsonProperty("id") String id,
            @JsonProperty("updated_at") String updatedAt,
            @JsonProperty("version") Long version,
            @JsonProperty("is_deleted") Boolean isDeleted,
            @JsonProperty("custom_attribute_values") Map<String, CatalogCustomAttributeValue> customAttributeValues,
            @JsonProperty("catalog_v1_ids") List<CatalogV1Id> catalogV1Ids,
            @JsonProperty("present_at_all_locations") Boolean presentAtAllLocations,
            @JsonProperty("present_at_location_ids") List<String> presentAtLocationIds,
            @JsonProperty("absent_at_location_ids") List<String> absentAtLocationIds,

44.2.0.20250521

public final class CatalogObject {
    private final Value value;

    @JsonCreator(mode = JsonCreator.Mode.DELEGATING)
    private CatalogObject(Value value) {
        this.value = value;
    }

    public <T> T visit(Visitor<T> visitor) {
        return value.visit(visitor);
    }

    public static CatalogObject item(CatalogObjectItem value) {
        return new CatalogObject(new ItemValue(value));
    }

    public static CatalogObject image(CatalogObjectImage value) {
        return new CatalogObject(new ImageValue(value));
    }

    public static CatalogObject category(CatalogObjectCategory value) {
        return new CatalogObject(new CategoryValue(value));
    }

Could you please advise:

  1. How should I determine the type of a CatalogObject under the new SDK structure?
  2. How can I retrieve the location-related information (presentAtAllLocations, presentAtLocationIds, absentAtLocationIds) from a CatalogObject in the upgraded SDK?

This will help us adjust our current logic for catalog data synchronization to align with the new SDK design.

Thank you very much for your guidance!

Best regards,
Murphy

:waving_hand: I’m Square Dev AI, here to help answer your question!
Based on the information you’ve provided, the following documentation will help answer your question:

Additional Documentation

Deprecated Items
Update Catalog Objects
Work with Images

If this documentation helped you find a solution, please check the box indicating that this reply solves the problem.
Otherwise one of our Developer Advocates will provide additional assistance shortly.