public static < T extends HasId > ExpandableField < T > setExpandableFieldId ( String newId , ExpandableField < T > currentObject ) { if ( currentObject == null || ( currentObject . isExpanded ( ) && ! Objects . equals ( currentObject . getId ( ) , newId ) ) ) { return new ExpandableField <> ( newId , null ) ; } return new ExpandableField <> ( newId , currentObject . getExpanded ( ) ) ; }
When setting a String ID for an ExpandableField we need to be careful about keeping the String ID and the expanded object in sync . If they specify a new String ID that is different from the ID within the expanded object we don t keep the object .