Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data API things to document #559

Open
2 tasks
gabizou opened this issue Dec 23, 2016 · 0 comments
Open
2 tasks

Data API things to document #559

gabizou opened this issue Dec 23, 2016 · 0 comments
Labels
help wanted We would appreciate contributions

Comments

@gabizou
Copy link
Member

gabizou commented Dec 23, 2016

This is more of a rolling issue that I'm going to be maintaining and some brain dumping on how certain aspects of Data API (and maybe other aspects of Sponge's systems, like the registry system) should be used.

  • Table for explaining what methods in DataView to use for what and when
Method Usage
getContainer() Used to get the top level container of the current view
get(DataQuery) Gets a raw Object, whether it's serialized or a DataView or a primitive type is unknown
getView() Gets a DataView child within this DataView, good for getting nested views for larger complex objects.
getBoolean() Gets a boolean out of the current DataView
getShort() Gets a short out of the current DataView
getByte() Gets a byte out of the current DataView`
getInt() Gets an int out of the current DataView
getLong() Gets a long out of the current DataView
getFloat() Gets a float out of the current DataView
getDouble() Gets a double out of the current DataView
getString() Gets a String out of the current DataView
getList() Gets a List of something out of the current DataView, this would be useful if you're attempting to get complex objects out of this list, such as a list of Maps. Not to be confused with a list of things that are DataSerializable or that are added as DataTranslatable (like UUIDs).
getViewList() Gets a List of DataViews. Useful for the list of DataViews that are separated from the current parent only by the given List. The path does not function past this point as the DataViews internally are parented only by themselves.
getSerializable() Gets a DataSerializable out of this DataView. Since DataSerializables are automatically serialized to DataViews upon insertion, the DataSerializable is deserialized from the internal DataView represented by the path as indicated by the DataQuery. Note that certain objects may not be deserializable, such as Entity objects.
getSerializableList() Gets a list of DataSerializables, follows the limitations of getList() or getViewList().
getObject() Gets an Object of type T that must have been registered as a DataTranslatable. These types of objects are declared in other libraries, not controlled by Sponge, and as such, cannot be marked as DataSerializable, but have been registered to be serializable by a DataTranslator. Objects such as these are Date, Instance, UUID, etc.
getObjectList() Similar to getObject and getViewList.
getCatalogType() Gets a CatalogType that is registered with Sponge. As CatalogTypes are uniquely identifiable by their String id, one can assume that if you have the id, and know the CatalogType base class, you can get the desired CatalogType instance of the id. Examples include BlockStates, ItemTypes, DyeColors, etc.
getCatalogTypeList() Similar to getCatalogType() but still represented as a list of Strings to be resolved by the GameRegistry.
  • More things as they come.
@gabizou gabizou added the help wanted We would appreciate contributions label Dec 23, 2016
@Inscrutable Inscrutable mentioned this issue Dec 23, 2016
16 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted We would appreciate contributions
Projects
None yet
Development

No branches or pull requests

1 participant