tcMenuJavaAPI
Classes | Public Member Functions | Static Public Member Functions | List of all members
com.thecoderscorner.menu.persist.JsonMenuItemSerializer Class Reference

Classes

class  CompatibleDateTimePersistor
 
class  MenuItemDeserialiser
 
class  MenuItemSerialiser
 

Public Member Functions

 JsonMenuItemSerializer (Consumer< GsonBuilder > builder)
 
Gson getGson ()
 
List< PersistedMenupopulateListInOrder (SubMenuItem node, MenuTree menuTree, boolean processingRoot)
 
String itemsToCopyText (MenuItem startingPoint, MenuTree tree)
 
List< PersistedMenucopyTextToItems (String items)
 
MenuTree newMenuTreeWithItems (String tcMenuCopy)
 

Static Public Member Functions

static boolean checkItemValueCanPersist (PersistedMenu persistedMenu)
 
static JsonObject getJsonObjOrThrow (JsonObject object, String child) throws IOException
 
static String getJsonStrOrThrow (JsonObject object, String child) throws IOException
 
static int getJsonIntOrThrow (JsonObject object, String child) throws IOException
 

Detailed Description

Creates a menu serializer instance that can convert menu structures to and from JSON format. In the simplest case just create a new instance of the class and you can use it to convert between formats.

    var jsonSerializer = new JsonMenuItemSerializer();
    var tree = jsonSerializer.newMenuTreeWithItems(textCopiedFromTcMenuDesigner);
    var json = jsonSerializer.itemsToCopyText(MenuTree.ROOT, tree);

Member Function Documentation

◆ checkItemValueCanPersist()

static boolean com.thecoderscorner.menu.persist.JsonMenuItemSerializer.checkItemValueCanPersist ( PersistedMenu  persistedMenu)
static

There are some menu types that should not have a default value, these generally don't have a value associated with them that can be easily saved, such as lists, action items, builder items and submenus.

Parameters
persistedMenuthe item to check
Returns
true if the item value can be persisted, otherwise false

The documentation for this class was generated from the following file: