Tabnine Logo
DataContainer.getSerializable
Code IndexAdd Tabnine to your IDE (free)

How to use
getSerializable
method
in
org.spongepowered.api.data.DataContainer

Best Java code snippets using org.spongepowered.api.data.DataContainer.getSerializable (Showing top 5 results out of 315)

origin: SpongePowered/SpongeAPI

@Test
public void testGetSerializable() throws Exception {
  initGame();
  List<String> myList = ImmutableList.of("foo", "bar", "baz");
  SimpleData temp = new SimpleData(1, 2.0, "foo", myList);
  DataContainer container = temp.toContainer();
  Optional<SimpleData> fromContainer = container.getSerializable(of(), SimpleData.class);
  assertTrue(fromContainer.isPresent());
  assertTrue(Objects.equal(fromContainer.get(), temp));
  assertTrue(container.contains(of("myStringList")));
  assertTrue(container.getStringList(of("myStringList")).get().equals(myList));
}
origin: EngineHub/CraftBook

@Override
public Optional<KeyLockData> from(DataContainer container) {
  if (container.contains(CraftBookKeys.KEY_LOCK.getQuery())) {
    return Optional.of(new KeyLockData(container.getSerializable(CraftBookKeys.KEY_LOCK.getQuery(), ItemStackSnapshot.class).get()));
  }
  return Optional.empty();
}
origin: EngineHub/CraftBook

@Override
public Optional<ICData> from(DataContainer container) {
  if (container.contains(CraftBookKeys.IC_DATA.getQuery())) {
    try {
      Class<SerializedICData> clazz = (Class<SerializedICData>) Class.forName(container.getString(DataQuery.of("ICDataClass")).orElse(SerializedICData.class.getName()));
      return Optional.of(new ICData(container.getSerializable(CraftBookKeys.IC_DATA.getQuery(), clazz).get()));
    } catch (ClassNotFoundException e) {
      e.printStackTrace();
    }
  }
  return Optional.empty();
}
origin: EngineHub/CraftBook

@Override
public Optional<EmbeddedBlockBagData> from(DataContainer container) {
  if (container.contains(CraftBookKeys.EMBEDDED_BLOCK_BAG.getQuery())) {
    return Optional.of(new EmbeddedBlockBagData(container.getSerializable(CraftBookKeys.EMBEDDED_BLOCK_BAG.getQuery(),
        EmbeddedBlockBag.class).get()));
  }
  return Optional.empty();
}
origin: SpongePowered/Cookbook

@Override
public Optional<HomeData> from(DataContainer container) {
  if (!container.contains(MyHomes.DEFAULT_HOME, MyHomes.HOMES)) {
    return Optional.empty();
  }
  // Loads the structure defined in toContainer
  this.defaultHome = container.getSerializable(MyHomes.DEFAULT_HOME.getQuery(), Home.class).get();
  // Loads the map of homes
  this.homes = Maps.newHashMap();
  DataView homes = container.getView(MyHomes.HOMES.getQuery()).get();
  for (DataQuery homeQuery : homes.getKeys(false)) {
    homes.getSerializable(homeQuery, Home.class)
        .ifPresent(home -> this.homes.put(homeQuery.toString(), home));
  }
  return Optional.of(this);
}
org.spongepowered.api.dataDataContainergetSerializable

Popular methods of DataContainer

  • set
  • createNew
    Creates a new DataContainer with the provided org.spongepowered.api.data.DataView.SafetyMode.
  • get
  • contains
  • getInt
  • getString
  • getView
  • createView
  • getLong
  • copy
  • getBoolean
  • getBooleanList
  • getBoolean,
  • getBooleanList,
  • getByteList,
  • getCharacterList,
  • getDouble,
  • getDoubleList,
  • getFloatList,
  • getIntegerList,
  • getList

Popular in Java

  • Start an intent from android
  • getExternalFilesDir (Context)
  • onRequestPermissionsResult (Fragment)
  • startActivity (Activity)
  • IOException (java.io)
    Signals a general, I/O-related error. Error details may be specified when calling the constructor, a
  • BigInteger (java.math)
    An immutable arbitrary-precision signed integer.FAST CRYPTOGRAPHY This implementation is efficient f
  • Iterator (java.util)
    An iterator over a sequence of objects, such as a collection.If a collection has been changed since
  • Cipher (javax.crypto)
    This class provides access to implementations of cryptographic ciphers for encryption and decryption
  • JFrame (javax.swing)
  • JTextField (javax.swing)
  • 21 Best IntelliJ Plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now