Added GetJson interface
This commit is contained in:
parent
84c6718c8e
commit
ee5527a3de
@ -1,4 +1,4 @@
|
|||||||
#Wed, 05 Dec 2018 17:57:49 +0100
|
#Wed, 05 Dec 2018 18:03:39 +0100
|
||||||
annotation.processing.enabled=true
|
annotation.processing.enabled=true
|
||||||
annotation.processing.enabled.in.editor=false
|
annotation.processing.enabled.in.editor=false
|
||||||
annotation.processing.processors.list=
|
annotation.processing.processors.list=
|
||||||
|
36
src/opensesim/sesim/interfaces/GetJson.java
Normal file
36
src/opensesim/sesim/interfaces/GetJson.java
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018, tohe
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright notice, this
|
||||||
|
* list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
|
* and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||||
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
package opensesim.sesim.interfaces;
|
||||||
|
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author tohe
|
||||||
|
*/
|
||||||
|
public interface GetJson {
|
||||||
|
JSONObject getJson();
|
||||||
|
}
|
@ -31,6 +31,7 @@ import javax.swing.JPanel;
|
|||||||
import opensesim.gui.util.Json;
|
import opensesim.gui.util.Json;
|
||||||
import opensesim.gui.util.Json.Import;
|
import opensesim.gui.util.Json.Import;
|
||||||
import opensesim.sesim.interfaces.Configurable;
|
import opensesim.sesim.interfaces.Configurable;
|
||||||
|
import opensesim.sesim.interfaces.GetJson;
|
||||||
import opensesim.util.idgenerator.Id;
|
import opensesim.util.idgenerator.Id;
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
@ -40,11 +41,10 @@ import org.json.JSONObject;
|
|||||||
*
|
*
|
||||||
* @author 7u83 <7u83@mail.ru>
|
* @author 7u83 <7u83@mail.ru>
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractAsset {
|
public abstract class AbstractAsset implements GetJson {
|
||||||
|
|
||||||
World world;
|
World world;
|
||||||
|
|
||||||
|
|
||||||
private String symbol;
|
private String symbol;
|
||||||
private String name;
|
private String name;
|
||||||
private String description;
|
private String description;
|
||||||
@ -52,12 +52,14 @@ public abstract class AbstractAsset {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
|
*
|
||||||
* @param world
|
* @param world
|
||||||
* @param cfg
|
* @param cfg
|
||||||
*/
|
*/
|
||||||
public AbstractAsset(World world, JSONObject cfg) {
|
public AbstractAsset(World world, JSONObject cfg) {
|
||||||
if (world == null)
|
if (world == null) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
symbol = cfg.getString("symbol");
|
symbol = cfg.getString("symbol");
|
||||||
name = cfg.getString("name");
|
name = cfg.getString("name");
|
||||||
decimals = cfg.optInt("decimals", 0);
|
decimals = cfg.optInt("decimals", 0);
|
||||||
@ -65,8 +67,6 @@ public abstract class AbstractAsset {
|
|||||||
this.world = world;
|
this.world = world;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public abstract String getTypeName();
|
public abstract String getTypeName();
|
||||||
|
|
||||||
public int getDecimals() {
|
public int getDecimals() {
|
||||||
@ -160,6 +160,7 @@ public abstract class AbstractAsset {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public JSONObject getJson() {
|
public JSONObject getJson() {
|
||||||
JSONObject cfg = new JSONObject();
|
JSONObject cfg = new JSONObject();
|
||||||
cfg.put(World.JKEYS.ASSET_TYPE, this.getClass().getName());
|
cfg.put(World.JKEYS.ASSET_TYPE, this.getClass().getName());
|
||||||
|
Loading…
Reference in New Issue
Block a user