| package org.apache.cayenne.demo.model.auto; |
| |
| import java.io.IOException; |
| import java.io.ObjectInputStream; |
| import java.io.ObjectOutputStream; |
| |
| import org.apache.cayenne.BaseDataObject; |
| import org.apache.cayenne.exp.property.BaseProperty; |
| import org.apache.cayenne.exp.property.NumericIdProperty; |
| import org.apache.cayenne.exp.property.PropertyFactory; |
| import org.apache.cayenne.exp.property.StringProperty; |
| |
| import com.fasterxml.jackson.databind.node.ObjectNode; |
| |
| /** |
| * Class _TestJson was generated by Cayenne. |
| * It is probably a good idea to avoid changing this class manually, |
| * since it may be overwritten next time code is regenerated. |
| * If you need to make any customizations, please use subclass. |
| */ |
| public abstract class _TestJson extends BaseDataObject { |
| |
| private static final long serialVersionUID = 1L; |
| |
| public static final NumericIdProperty<Integer> ID_PK_PROPERTY = PropertyFactory.createNumericId("id", "TestJson", Integer.class); |
| public static final String ID_PK_COLUMN = "id"; |
| |
| public static final BaseProperty<ObjectNode> JSON = PropertyFactory.createBase("json", ObjectNode.class); |
| public static final StringProperty<String> NAME = PropertyFactory.createString("name", String.class); |
| |
| protected ObjectNode json; |
| protected String name; |
| |
| |
| public void setJson(ObjectNode json) { |
| beforePropertyWrite("json", this.json, json); |
| this.json = json; |
| } |
| |
| public ObjectNode getJson() { |
| beforePropertyRead("json"); |
| return this.json; |
| } |
| |
| public void setName(String name) { |
| beforePropertyWrite("name", this.name, name); |
| this.name = name; |
| } |
| |
| public String getName() { |
| beforePropertyRead("name"); |
| return this.name; |
| } |
| |
| @Override |
| public Object readPropertyDirectly(String propName) { |
| if(propName == null) { |
| throw new IllegalArgumentException(); |
| } |
| |
| switch(propName) { |
| case "json": |
| return this.json; |
| case "name": |
| return this.name; |
| default: |
| return super.readPropertyDirectly(propName); |
| } |
| } |
| |
| @Override |
| public void writePropertyDirectly(String propName, Object val) { |
| if(propName == null) { |
| throw new IllegalArgumentException(); |
| } |
| |
| switch (propName) { |
| case "json": |
| this.json = (ObjectNode)val; |
| break; |
| case "name": |
| this.name = (String)val; |
| break; |
| default: |
| super.writePropertyDirectly(propName, val); |
| } |
| } |
| |
| private void writeObject(ObjectOutputStream out) throws IOException { |
| writeSerialized(out); |
| } |
| |
| private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { |
| readSerialized(in); |
| } |
| |
| @Override |
| protected void writeState(ObjectOutputStream out) throws IOException { |
| super.writeState(out); |
| out.writeObject(this.json); |
| out.writeObject(this.name); |
| } |
| |
| @Override |
| protected void readState(ObjectInputStream in) throws IOException, ClassNotFoundException { |
| super.readState(in); |
| this.json = (ObjectNode)in.readObject(); |
| this.name = (String)in.readObject(); |
| } |
| |
| } |