1 /*******************************************************************************
2 * Copyright (c) 2007, 2012 Association for Decentralized Information Management in
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.modeling.typicals;
14 import java.io.IOException;
15 import java.util.ArrayList;
16 import java.util.List;
18 import org.simantics.databoard.Bindings;
19 import org.simantics.databoard.binding.Binding;
20 import org.simantics.databoard.serialization.SerializationException;
21 import org.simantics.databoard.serialization.Serializer;
22 import org.simantics.db.Metadata;
23 import org.simantics.db.Resource;
24 import org.simantics.db.Session;
27 * @author Tuukka Lehtonen
29 public class TypicalSynchronizationMetadata implements Metadata {
31 private static final Binding BINDING =
32 Bindings.getBindingUnchecked(TypicalSynchronizationMetadata.class);
33 private static final Serializer SERIALIZER =
34 Bindings.getSerializerUnchecked(BINDING);
36 public List<Resource> synchronizedTypicals;
38 public TypicalSynchronizationMetadata() {
42 public byte[] serialise(Session session) {
44 return SERIALIZER.serialize(this);
45 } catch (IOException e) {
47 throw new RuntimeException(e);
51 public static TypicalSynchronizationMetadata deserialise(Session session, byte[] input) {
53 TypicalSynchronizationMetadata metadata = new TypicalSynchronizationMetadata();
54 metadata.synchronizedTypicals = new ArrayList<Resource>();
58 return (TypicalSynchronizationMetadata) SERIALIZER.deserialize(input);
59 } catch (SerializationException e) {
61 } catch (IOException e) {
68 * @param typicalInstance
71 public TypicalSynchronizationMetadata addTypical(Resource typicalInstance) {
72 synchronizedTypicals.add(typicalInstance);
76 public List<Resource> getTypicals() {
77 return synchronizedTypicals;