persistenceManager().currentTransaction().begin(); CustomClass customObj = new CustomClass(); customobj.setName("someName"); //set other values persistenceManager.makePeristent(customObj);//persist //comment this //SomeUtil.getRoot().getChildElements().add(customObj);//add to its owner persistenceManager.currentTransaction().commit();
public CustomClass getindexedListobj(int index) { CustomClass tmp = null; for(CustomClass o : this.listobj) if(o.getId() == index) { tmp = o; break; } if(tmp == null) { tmp = new CustomClass(); this.listobj.add(tmp); } return tmp; }
CustomClass customClassInstance = new CustomClass(); customClassInstance.setParam1(...); //...and so on Call<JsonArray> peticion= RetrofitClient.getRetrofitClient(getActivity()).sendParameters(settings.getString("imei", ""), settings.getString("idCliente", ""), customClassInstance);
public void testMarshallingNestedSerializableSubclass() throws Exception { Child1 child1Obj = new Child1(1234, "1234"); Child2 child2Obj = new Child2(2345, "2345", child1Obj); byte[] bytes = marshaller.objectToByteBuffer(child2Obj); Child2 readChild2 = (Child2) marshaller.objectFromByteBuffer(bytes); assertEquals(2345, readChild2.someInt); assertEquals("2345", readChild2.getId()); assertEquals(1234, readChild2.getChild1Obj().someInt); assertEquals("1234", readChild2.getChild1Obj().getId()); }
public void testTreeSetWithComparator() throws Exception { Set<Human> treeSet = new TreeSet<>(new HumanComparator()); for (int i = 0; i < 10; i++) { treeSet.add(new Human().age(i)); } marshallAndAssertEquality(treeSet); }
public void testExternalAndInternalWithOffset() throws Exception { PojoWithExternalAndInternal obj = new PojoWithExternalAndInternal(new Human().age(23), "value"); byte[] bytes = marshaller.objectToByteBuffer(obj); bytes = prependBytes(new byte[]{1, 2, 3}, bytes); Object readObj = marshaller.objectFromByteBuffer(bytes, 3, bytes.length); assertEquals(obj, readObj); }
public void testModificationsOnSameCustomKey() { Cache<InvalidatedPojo, String> cache1 = cache(0, "invlSync"); Cache<InvalidatedPojo, String> cache2 = cache(1, "invlSync"); InvalidatedPojo key = new InvalidatedPojo(); cache2.put(key, "1"); cache1.put(key, "2"); // Marshalling is done eagerly now, so no need for extra serialization checks assertSerializationCounts(2, 0); cache1.put(key, "3"); // +2 carried on here. assertSerializationCounts(3, 0); }
private GlobalConfigurationBuilder createMultiForeignExternalizerGlobalConfig(int id, boolean doSetId) { GlobalConfigurationBuilder builder = new GlobalConfigurationBuilder(); if (doSetId) builder.serialization().addAdvancedExternalizer(id, new IdViaConfigObj.Externalizer()); else builder.serialization().addAdvancedExternalizer(new IdViaConfigObj.Externalizer()); builder.serialization().addAdvancedExternalizer(new IdViaAnnotationObj.Externalizer()); builder.serialization().addAdvancedExternalizer(3456, new IdViaBothObj.Externalizer()); return builder; }
protected GlobalConfigurationBuilder createForeignExternalizerGlobalConfig() { GlobalConfigurationBuilder builder = new GlobalConfigurationBuilder().clusteredDefault(); builder.serialization() .addAdvancedExternalizer(1234, new IdViaConfigObj.Externalizer()) .addAdvancedExternalizer(new IdViaAnnotationObj.Externalizer()) .addAdvancedExternalizer(3456, new IdViaBothObj.Externalizer()); return builder; }
@Override protected void createCacheManagers() throws Throwable { ConfigurationBuilder builder = getDefaultClusteredCacheConfig( CacheMode.REPL_ASYNC, false); createClusteredCaches(2, "concurrentMarshaller", builder); }
public void testImmutableResponseMarshalling() throws Exception { marshallAndAssertEquality(UnsuccessfulResponse.EMPTY); marshallAndAssertEquality(UnsureResponse.INSTANCE); }
public void testByteArray() throws Exception { byte[] bytes = new byte[]{1, 2, 3}; marshallAndAssertByteArrayEquality(bytes); }
@Override public PojoAnnotated readObject(ObjectInput input) throws IOException, ClassNotFoundException { return new PojoAnnotated(input.readInt(), input.readBoolean()); } }
@Override public PojoWithExternalAndInternal readObject(ObjectInput input) throws IOException, ClassNotFoundException { Human human = (Human) input.readObject(); String value = (String) input.readObject(); return new PojoWithExternalAndInternal(human, value); }
List<CustomClass> foo = ArrayList<CustomClass> CustomClass cust = new CustomClass(); cust.setResult("Test"); cust.setCount(1); foo.add(cust);
@Override protected GlobalConfigurationBuilder createForeignExternalizerGlobalConfig() { GlobalConfigurationBuilder builder = new GlobalConfigurationBuilder().clusteredDefault(); builder.serialization() .addAdvancedExternalizer(1234, new IdViaConfigObj.Externalizer()) .addAdvancedExternalizer(new IdViaAnnotationObj.Externalizer()) .addAdvancedExternalizer(3456, new IdViaBothObj.Externalizer()); return builder; }
public void testSingleFlagMarshalling() throws Exception { marshallAndAssertEquality(Flag.FORCE_SYNCHRONOUS); }
class CustomClassJsFactory : public QObject { Q_OBJECT public: CustomClassFactory(QJSEngine* engine) : m_engine(engine) {} Q_INVOKABLE QJSValue createInstance() { // The engine takes ownership and destroys the object if no longer required. return m_engine->newQObject(new CustomClass()); } private: QJSEngine* m_engine; }
public void testConcurrentHashMap() throws Exception { ConcurrentHashMap<Integer, String> map = new ConcurrentHashMap<>(); map.put(1, "v1"); map.put(2, "v2"); map.put(3, "v3"); marshallAndAssertEquality(map); }
public class MyClass_ extends MyClass { private CustomClass member; public synchronized CustomClass getMember() { if (member == null){ member == new CustomClass(); } return member; } }