Ignore:
Timestamp:
09/23/13 18:54:07 (11 years ago)
Author:
psniegowski
Message:

HIGHLIGHTS:

  • add SimultorProviders? hierarchy
  • start Framsticks server over SSH
  • FJF compatible with Framsticks 4.0rc3
  • reading and writing of standard.expt
  • a proof-of-concept implementation of StandardExperiment?

CHANGELOG:
Optionally return FreeAccess? from registry.

Add SimulatorRange?.

StandardExperiment? with genotypes circulation.

Automate registration around StandardState?.

More improvements to StandardExperiment?.

Skeleton version of StandardExperiment?.

Test saving of StandardState?.

Standard experiment state is being loaded.

More development towards StandardState? reading.

Work on reading standard experiment state.

Add classes for standard experiment.

Update example standard.expt

Add FreeAccess? and FreeObject?.

Made compatible with version 4.0rc3

Change deserialization policy.

Improve SSH support.

Working running simulator over SSH.

Fix joining bug in Experiment.

Working version of SimulatorRunner?.

Add more SimulatorProviders?.

Working PrimeExperimentTest? with 4.0rc3

Add references to deserialization.

Add OpaqueObject? and it's serialization.

Add deserialization of dictionaries.

Partial implementation of deserialization.

Add more tests for deserialization.

Prepare tests for deserialization.

Add proper result to prime experiment test.

Minor fixes to simulators providers.

Draft version of SimulatorProvider?.

Add SimulatorProvider? interface.

Location:
java/main/src/main/java/com/framsticks/params
Files:
4 added
17 edited

Legend:

Unmodified
Added
Removed
  • java/main/src/main/java/com/framsticks/params/AccessOperations.java

    r105 r107  
    9999        public static Access loadAll(@Nullable final Access rootAccess, Source source, final Registry registry) {
    100100                final MultiParamLoader loader = new MultiParamLoader();
     101                log.trace("loading all from {} into {}", source, rootAccess);
    101102                loader.setNewSource(source);
    102103                final LinkedList<Access> accessesStack = new LinkedList<>();
     
    146147
    147148                                                        if (p instanceof ListParam) {
    148                                                                 ListAccess listAccess = Casting.assertCast(ListAccess.class, registry.prepareAccess(p));
    149                                                                 listAccess.select(a.get(p, Object.class));
     149                                                                ListAccess listAccess = Casting.assertCast(ListAccess.class, registry.prepareAccess(p, true));
     150                                                                Object list = a.get(p, Object.class);
     151                                                                if (list == null) {
     152                                                                        list = listAccess.createAccessee();
     153                                                                        a.set(p, list);
     154                                                                }
     155                                                                listAccess.select(list);
    150156                                                                parent.set(new Pair<Access, CompositeParam>(listAccess, listAccess.prepareParamFor(Integer.toString(listAccess.getParamCount()))));
    151157
     
    157163
    158164                                        if (parent.get() == null) {
     165                                                log.trace("{} cannot be placed in {}", name, a);
    159166                                                accessIterator.remove();
    160167                                        }
     
    162169
    163170                                if (parent.get() == null) {
    164                                         throw new FramsticksException().msg("failed to find place for loaded object").arg("name", name);
    165                                 }
    166 
    167                                 currentAccess.set(registry.prepareAccess(parent.get().second));
     171                                        throw new FramsticksException().msg("failed to find place for loaded object").arg("name", name); //.arg("in", accessesStack);
     172                                }
     173
     174                                currentAccess.set(registry.prepareAccess(parent.get().second, true));
    168175                                Object object = parent.get().first.get(parent.get().second, Object.class);
    169176                                if (object != null) {
     
    200207        }
    201208
    202         public static void saveAll(Access access, Sink sink, Registry registry) {
     209        public static <S extends Sink> S saveAll(Access access, S sink, Registry registry) {
    203210                if (access instanceof ObjectAccess) {
    204211                        savePrimitives(access, sink);
     
    209216                                continue;
    210217                        }
    211                         saveAll(registry.prepareAccess(p).select(child), sink, registry);
    212                 }
     218                        saveAll(registry.prepareAccess(p, true).select(child), sink, registry);
     219                }
     220                return sink;
    213221        }
    214222
     
    219227                                continue;
    220228                        }
    221                         savePrimitives(registry.prepareAccess(p).select(child), sink);
     229                        savePrimitives(registry.prepareAccess(p, true).select(child), sink);
    222230                }
    223231        }
     
    297305                                        }
    298306
    299                                         return registry.prepareAccess(result).select(objectAccess.get(result, Object.class));
     307                                        return registry.prepareAccess(result, true).select(objectAccess.get(result, Object.class));
    300308                                }
    301309                        });
     
    323331                        }
    324332                        if ((param.getFlags() & ParamFlags.DONTLOAD) == 0) {
    325                                 int retFlags = access.set((ValueParam) param, entry.value);
     333                                ValueParam valueParam = (ValueParam) param;
     334                                // Object object = valueParam.deserialize(entry.value, null,  Object.class);
     335                                int retFlags = access.set(valueParam, entry.value);
    326336                                if ((retFlags & (PSET_HITMIN | PSET_HITMAX)) != 0) {
    327337                                        String which = ((retFlags & PSET_HITMIN) != 0) ? "small" : "big";
     
    440450         */
    441451        public static <T, F> T convert(Class<T> toJavaClass, F from, Registry registry) {
     452                log.trace("converting from {} to {}", from, toJavaClass);
    442453                if (toJavaClass.equals(from.getClass())) {
    443454                        return toJavaClass.cast(from);
     
    478489
    479490                                if (avp instanceof CompositeParam) {
    480                                         assureEquality(registry.prepareAccess((CompositeParam) avp).select(oa), registry.prepareAccess((CompositeParam) bvp).select(ob), registry);
     491                                        assureEquality(registry.prepareAccess((CompositeParam) avp, false).select(oa), registry.prepareAccess((CompositeParam) bvp, false).select(ob), registry);
    481492                                        continue;
    482493                                }
  • java/main/src/main/java/com/framsticks/params/ArrayListAccess.java

    r105 r107  
    137137                                return new Iterator<Param>() {
    138138
    139                                         protected ListIterator<Object> internal = list.listIterator();
     139                                        protected final ListIterator<Object> internal = list.listIterator();
    140140
    141141                                        @Override
  • java/main/src/main/java/com/framsticks/params/FramsClassBuilder.java

    r101 r107  
    4242
    4343        public static FramsClass readFromStream(InputStream stream) {
    44                 return Loaders.loadFramsClass(new FileSource(stream));
     44                return readFromSource(new FileSource(stream));
     45        }
     46
     47        public static FramsClass readFromSource(Source source) {
     48                return Loaders.loadFramsClass(source);
    4549        }
    4650
  • java/main/src/main/java/com/framsticks/params/ParamCandidate.java

    r105 r107  
    8080        protected final OneTime<Method> remover = new OneTime<>("remover");
    8181        protected final OneTime<Class<? extends Param>> paramType = new OneTime<>("paramType");
     82        protected final OneTime<String> stringType = new OneTime<>("stringType");
    8283
    8384        protected int flags = 0;
     
    278279                if (!paramAnnotation.paramType().equals(Param.class)) {
    279280                        paramType.set(paramAnnotation.paramType());
     281                }
     282                if (!"".equals(paramAnnotation.stringType())) {
     283                        stringType.set(paramAnnotation.stringType());
    280284                }
    281285                if (member instanceof Field) {
     
    371375                protected final List<ParamCandidate> order;
    372376                protected final java.util.Set<Class<?>> dependantClasses = new HashSet<>();
     377                protected final java.util.Set<String> dependantClassesFromInfo = new HashSet<>();
    373378
    374379                /**
     
    398403                        return dependantClasses;
    399404                }
     405
     406                public java.util.Set<String> getDependentClassesFromInfo() {
     407                        return dependantClassesFromInfo;
     408                }
    400409        }
    401410
     
    432441                                        result.dependantClasses.add(r);
    433442                                }
    434 
     443                                for (String i : fa.registerFromInfo()) {
     444                                        result.dependantClassesFromInfo.add(i);
     445                                }
    435446
    436447                                final List<String> order = Arrays.asList(fa.order());
     
    575586
    576587        public ParamBuilder induceParamType(ParamBuilder builder) {
     588
     589                if (stringType.has()) {
     590                        return builder.type(stringType.get());
     591                }
     592
    577593                Method method = getCaller();
    578594                if (method == null) {
  • java/main/src/main/java/com/framsticks/params/ParamsUtil.java

    r105 r107  
    22
    33import java.util.ArrayList;
     4// import java.util.HashMap;
    45import java.util.List;
    56import java.util.Map;
     7import java.util.TreeMap;
     8import java.util.regex.Matcher;
     9import java.util.regex.Pattern;
    610
    711import javax.annotation.Nonnull;
    812
     13// import org.apache.logging.log4j.Logger;
     14// import org.apache.logging.log4j.LogManager;
     15
    916import com.framsticks.util.FramsticksException;
     17import com.framsticks.util.lang.Numbers;
    1018
    1119
     
    1624 */
    1725public abstract class ParamsUtil {
     26        // private final static Logger log = LogManager.getLogger(ParamsUtil.class.getName());
     27
    1828
    1929        public static String readSourceToString(Source source) {
     
    212222                                return true;
    213223                        }
     224                        if (type.equals(OpaqueObject.class)) {
     225                                builder.append(value.toString());
     226                                return true;
     227                        }
    214228                        throw new FramsticksException().msg("invalid type for serialization").arg("type", type);
    215229                }
     
    233247        }
    234248
     249        public static class DeserializationContext {
     250
     251                public static final Pattern OPAQUE_OBJECT_PATTERN = Pattern.compile("^(\\w+)<0x([a-fA-F0-9]+)>$");
     252
     253                @SuppressWarnings("serial")
     254                public static class Exception extends FramsticksException {
     255                }
     256
     257                protected final ArrayList<Object> objects = new ArrayList<>();
     258                protected int cursor = 0;
     259                protected final String input;
     260
     261                /**
     262                 * @param input
     263                 */
     264                public DeserializationContext(String input) {
     265                        this.input = input;
     266                        cursor = 0;
     267                }
     268
     269                protected boolean isFinished() {
     270                        return cursor == input.length();
     271                }
     272
     273                protected boolean is(char value) {
     274                        if (isFinished()) {
     275                                throw fail().msg("input ended");
     276                        }
     277                        return input.charAt(cursor) == value;
     278                }
     279
     280                protected boolean isOneOf(String values) {
     281                        if (isFinished()) {
     282                                throw fail().msg("input ended");
     283                        }
     284                        return values.indexOf(input.charAt(cursor)) != -1;
     285                }
     286
     287                protected char at() {
     288                        return input.charAt(cursor);
     289                }
     290
     291                protected char at(int pos) {
     292                        return input.charAt(pos);
     293                }
     294
     295                protected FramsticksException fail() {
     296                        return new Exception().arg("at", cursor).arg("input", input);
     297                }
     298
     299                protected void force(char value) {
     300                        if (!is(value)) {
     301                                throw fail().msg("invalid character").arg("expected", value).arg("found", at());
     302                        }
     303                        next();
     304                }
     305
     306                protected boolean isAndNext(char value) {
     307                        if (!is(value)) {
     308                                return false;
     309                        }
     310                        next();
     311                        return true;
     312                }
     313
     314                protected void next() {
     315                        ++cursor;
     316                        // log.info("at: {}|{}", input.substring(0, cursor), input.substring(cursor));
     317                }
     318
     319                protected void goToNext(char value) {
     320                        while (cursor < input.length()) {
     321                                if (is(value)) {
     322                                        return;
     323                                }
     324                                next();
     325                        }
     326                        throw fail().msg("passed end").arg("searching", value);
     327                }
     328
     329
     330                protected String forceStringRemaining() {
     331                        int start = cursor;
     332                        while (true) {
     333                                goToNext('"');
     334                                if (at(cursor - 1) != '\\') {
     335                                        next();
     336                                        return input.substring(start, cursor - 1);
     337                                }
     338                                next();
     339                                // it is finishing that loop, because of throwing in goToNext()
     340                        }
     341                        // throw fail();
     342                }
     343
     344                public Object deserialize() {
     345                        if (isAndNext('[')) {
     346                                List<Object> list = new ArrayList<>();
     347                                objects.add(list);
     348                                while (!isAndNext(']')) {
     349                                        if (!list.isEmpty()) {
     350                                                force(',');
     351                                        }
     352                                        Object child = deserialize();
     353                                        list.add(child);
     354                                }
     355                                return list;
     356                        }
     357
     358                        if (isAndNext('{')) {
     359                                Map<String, Object> map = new TreeMap<>();
     360                                objects.add(map);
     361                                while (!isAndNext('}')) {
     362                                        if (!map.isEmpty()) {
     363                                                force(',');
     364                                        }
     365                                        force('"');
     366                                        String key = forceStringRemaining();
     367                                        force(':');
     368                                        Object value = deserialize();
     369                                        map.put(key, value);
     370                                }
     371                                return map;
     372                        }
     373
     374                        if (isAndNext('"')) {
     375                                return forceStringRemaining();
     376                        }
     377                        int start = cursor;
     378                        while (!isFinished() && !isOneOf("]},")) {
     379                                next();
     380                        }
     381                        if (start == cursor) {
     382                                throw fail().msg("empty value");
     383                        }
     384
     385                        String value = input.substring(start, cursor);
     386                        if (value.equals("null")) {
     387                                //TODO: add this to list?
     388                                return null;
     389                        }
     390
     391                        Matcher matcher = OPAQUE_OBJECT_PATTERN.matcher(value);
     392                        if (matcher.matches()) {
     393                                return new OpaqueObject(matcher.group(1), Long.parseLong(matcher.group(2), 16));
     394                        }
     395
     396
     397                        Object number = DeserializationContext.tryParseNumber(value);
     398                        if (number != null) {
     399                                return number;
     400                        }
     401
     402                        if (value.charAt(0) == '^') {
     403                                Integer reference = Numbers.parse(value.substring(1), Integer.class);
     404                                if (reference == null) {
     405                                        throw fail().msg("invalid reference").arg("reference", reference);
     406                                }
     407                                return objects.get(reference);
     408                        }
     409                        //TODO: parse ^
     410                        //TODO: parse opaque object
     411                        throw fail().msg("unknown entity");
     412
     413                }
     414
     415                public static Object tryParseNumber(String value) {
     416                        Integer i = Numbers.parse(value, Integer.class);
     417                        if (i != null) {
     418                                return i;
     419                        }
     420
     421                        Double d = Numbers.parse(value, Double.class);
     422                        if (d != null) {
     423                                return d;
     424                        }
     425
     426                        return null;
     427                }
     428        }
     429
     430
     431        public static Object deserialize(String value) {
     432                Object number = DeserializationContext.tryParseNumber(value);
     433                if (number != null) {
     434                        return number;
     435                }
     436
     437                if (!value.startsWith(SERIALIZED)) {
     438                        return value;
     439                }
     440                return new DeserializationContext(value.substring(SERIALIZED.length())).deserialize();
     441        }
     442
    235443        public static <T> T deserialize(String value, Class<T> type) {
    236                 return null;
     444                Object object = deserialize(value);
     445
     446                return type.cast(object);
    237447        }
    238448
  • java/main/src/main/java/com/framsticks/params/PrimitiveParam.java

    r105 r107  
    33import com.framsticks.util.FramsticksException;
    44import com.framsticks.util.Misc;
    5 import com.framsticks.util.lang.Casting;
    65import com.framsticks.util.lang.Numbers;
    76import com.framsticks.util.lang.Strings;
     
    5150                                        return type.cast(value);
    5251                                }
    53                                 // if (Number.class.isAssignableFrom(type)) {
    5452                                return Numbers.parse((String) value, type);
    55                                 // }
    56                                 // return null;
     53                        } if ((value instanceof Integer) && (type.equals(Double.class))) {
     54                                return type.cast(new Double((Integer) value));
    5755                        } else {
    5856                                return type.cast(value);
    5957                        }
    6058                } catch (ClassCastException e) {
    61                         throw new FramsticksException().msg("failed to cast").cause(e).arg("param", this).arg("actual", value.getClass()).arg("requested", type);
     59                        throw new FramsticksException().msg("failed to cast").cause(e).arg("param", this).arg("actual", value.getClass()).arg("requested", type).arg("value", value);
    6260                }
    6361        }
     
    9997        }
    10098
    101         @Override
    10299        public <T> String serialize(T value) {
    103100                return Strings.toStringNullProof(value);
    104101        }
    105102
    106         @Override
    107         public <T> T deserialize(String text, T currentValue, Class<T> type) {
    108                 try {
    109                         return Casting.nullOrThrowCast(type, reassign(text, currentValue).getValue());
    110                 } catch (CastFailure e) {
    111                         return null;
    112                 }
    113         }
    114103}
  • java/main/src/main/java/com/framsticks/params/PropertiesAccess.java

    r105 r107  
    112112        }
    113113}
     114
  • java/main/src/main/java/com/framsticks/params/PropertiesObject.java

    r105 r107  
    11package com.framsticks.params;
    22
    3 import java.util.Map;
    4 import java.util.TreeMap;
    5 
    6 import com.framsticks.util.lang.Casting;
    7 
    8 public class PropertiesObject {
    9 
    10         protected final String framsTypeName;
    11         protected final Map<String, Object> values = new TreeMap<>();
     3public class PropertiesObject extends MapBasedObject {
    124
    135        /**
    14          * @param framsTypeName
     6         *
    157         */
    168        public PropertiesObject(String framsTypeName) {
    17                 this.framsTypeName = framsTypeName;
     9                super(framsTypeName);
    1810        }
    1911
    20         public <T> void set(String id, T value) {
    21                 values.put(id, value);
    22         }
    23 
    24         public <T> T get(String id, Class<T> type) {
    25                 return Casting.nullOrThrowCast(type, values.get(id));
    26         }
    27 
    28         public void clear() {
    29                 values.clear();
    30         }
    31 
    32         public int size() {
    33                 return values.size();
    34         }
    35 
    36         @Override
    37         public String toString() {
    38                 return values.toString();
    39         }
    40 
    41         /**
    42          * @return the framsTypeName
    43          */
    44         public String getFramsTypeName() {
    45                 return framsTypeName;
    46         }
    4712}
  • java/main/src/main/java/com/framsticks/params/ReflectionAccess.java

    r105 r107  
    1111import com.framsticks.params.types.ProcedureParam;
    1212import com.framsticks.util.FramsticksException;
     13import com.framsticks.util.Misc;
    1314
    1415import static com.framsticks.util.lang.Containers.*;
     
    9091                        }
    9192                } catch (FramsticksException e) {
    92                         throw e.arg("param", param).arg("value", value).arg("access", this);
     93                        throw e.arg("param", param).arg("value", value).arg("value type", Misc.getClass(value)).arg("access", this);
    9394                }
    9495        }
  • java/main/src/main/java/com/framsticks/params/Registry.java

    r103 r107  
    88import com.framsticks.util.DoubleMap;
    99import com.framsticks.util.FramsticksException;
     10import com.framsticks.util.lang.Casting;
    1011import com.framsticks.util.lang.Strings;
    1112
     
    5354                        registerAndBuild(r);
    5455                }
     56
     57                for (String i : ParamCandidate.getAllCandidates(javaClass).getDependentClassesFromInfo()) {
     58                        putFramsClass(FramsClassBuilder.readFromStream(getClass().getResourceAsStream("/info/" + i + ".info")));
     59                }
    5560                return this;
    5661        }
     
    7681                try {
    7782                        if (!javaClasses.containsValue(javaClass)) {
     83                                registerAndBuild(javaClass);
     84                        }
     85
     86                        if (!javaClasses.containsValue(javaClass)) {
    7887                                throw new FramsticksException().msg("java class is not registered");
    7988                        }
     
    114123        }
    115124
    116         public @Nonnull Access prepareAccess(CompositeParam param) throws ConstructionException {
    117                 return wrapAccessWithListIfNeeded(param, createAccess(param.getContainedTypeName()));
    118         }
    119 
    120         public @Nonnull Access createAccess(@Nonnull String name) throws ConstructionException {
     125        public @Nonnull Access prepareAccess(CompositeParam param, boolean force) throws ConstructionException {
     126                return wrapAccessWithListIfNeeded(param, createAccess(param.getContainedTypeName(), force));
     127        }
     128
     129        public @Nonnull Access createAccess(@Nonnull Object object) throws ConstructionException {
     130                if (object instanceof MapBasedObject) {
     131                        return createAccess(((MapBasedObject) object).getFramsTypeName());
     132                }
     133                return createAccess(object.getClass());
     134        }
     135
     136        public @Nonnull Access createAccess(@Nonnull String name, boolean force) throws ConstructionException {
    121137                try {
    122138                        Strings.assureNotEmpty(name);
    123139                        FramsClass framsClass = getFramsClass(name);
    124140                        if (framsClass == null) {
    125                                 throw new ConstructionException().msg("framsclass is missing");
     141                                if (!force) {
     142                                        throw new ConstructionException().msg("framsclass is missing");
     143                                }
     144                                return new FreeAccess(name);
    126145                        }
    127146
     
    131150                        throw new FramsticksException().msg("failed to create access for name").arg("name", name).cause(e);
    132151                }
     152        }
     153
     154        public @Nonnull Access createAccess(@Nonnull String name) throws ConstructionException {
     155                return createAccess(name, false);
    133156        }
    134157
     
    166189
    167190        public Access bindAccessFor(Object object) {
    168                 return createAccess(object.getClass()).select(object);
     191                return createAccess(object).select(object);
     192        }
     193
     194        public Registry register(ParamsPackage paramsPackage) {
     195                paramsPackage.register(this);
     196                return this;
     197        }
     198
     199        public Registry registerAndBuild(ParamsPackage paramsPackage) {
     200                paramsPackage.setBuild(true);
     201                paramsPackage.register(this);
     202                return this;
     203        }
     204
     205        public Access bindAccessFor(Access parent, String paramName) {
     206                CompositeParam childParam = Casting.throwCast(CompositeParam.class, parent.getParam(paramName));
     207                return prepareAccess(childParam, true).select(parent.get(childParam, Object.class));
    169208        }
    170209
  • java/main/src/main/java/com/framsticks/params/UniqueListAccess.java

    r105 r107  
    187187        }
    188188
     189        public int setUidOf(Object value, String uid) {
     190                return uidAccess.select(value).set(uidName, uid);
     191        }
     192
     193        protected int uidCounter = 1;
     194
     195        public String generateNextUid() {
     196                return containedTypeName.substring(0, 1).toUpperCase() + Integer.toString(uidCounter++);
     197        }
     198
     199        public String findNextFreeUid() {
     200                String uid;
     201                do {
     202                        uid = generateNextUid();
     203                } while (get(uid, Object.class) != null);
     204                return uid;
     205        }
     206
    189207        protected int setByUid(Object object, String uid) {
    190208                if (uid == null) {
    191209                        uid = getUidOf(object);
    192210                        if (uid == null) {
    193                                 log.error("failed to set - missing uid");
    194                                 return 0;
     211                                uid = findNextFreeUid();
     212                                setUidOf(object, uid);
    195213                        }
    196214                }
     
    205223        @Override
    206224        public <T> int set(int i, T value) {
    207                 if (i != map.size()) {
    208                         throw new FramsticksUnsupportedOperationException().msg("setting element in unique list through index is available only for addition");
    209                 }
    210                 set(getUidOf(value), value);
    211                 return 0;
     225                if (value != null) {
     226                        if (i != map.size()) {
     227                                throw new FramsticksUnsupportedOperationException().msg("setting element in unique list through index is available only for addition");
     228                        }
     229                        set(getUidOf(value), value);
     230                        return 0;
     231                }
     232                if (i >= map.size()) {
     233                        throw new FramsticksUnsupportedOperationException().msg("invalid index for removal");
     234                }
     235                Object current = get(i, Object.class);
     236                return setByUid(null, getUidOf(current));
    212237        }
    213238
    214239        @Override
    215240        public <T> int set(String id, T value) {
     241                if (id == null) {
     242                        return setByUid(value, null);
     243                }
    216244                Integer i = Numbers.parse(id, Integer.class);
    217245                if (i != null) {
  • java/main/src/main/java/com/framsticks/params/ValueParam.java

    r105 r107  
    2828        }
    2929
    30         public abstract <T> String serialize(T value);
    31 
    32         public abstract <T> T deserialize(String text, T currentValue, Class<T> type);
     30        // public abstract <T> String serialize(T value);
    3331
    3432}
  • java/main/src/main/java/com/framsticks/params/annotations/FramsClassAnnotation.java

    r99 r107  
    1414        String[] order() default {};
    1515        Class<?>[] register() default {};
     16        String[] registerFromInfo() default {};
    1617}
  • java/main/src/main/java/com/framsticks/params/types/ListParam.java

    r105 r107  
    1616        }
    1717
    18         @Override
    19         public <T> String serialize(T value) {
    20                 return null;
    21         }
     18        // @Override
     19        // public <T> String serialize(T value) {
     20        //      return null;
     21        // }
    2222
    23         @Override
    24         public <T> T deserialize(String text, T currentValue, Class<T> type) {
    25                 return null;
    26         }
    2723}
  • java/main/src/main/java/com/framsticks/params/types/ObjectParam.java

    r105 r107  
    55import com.framsticks.params.CompositeParam;
    66import com.framsticks.params.ParamBuilder;
    7 import com.framsticks.params.ParamsUtil;
    87import com.framsticks.params.ReassignResult;
    98
     
    5150        }
    5251
    53         @Override
    54         public <T> String serialize(T value) {
    55                 return ParamsUtil.serialize(value);
    56         }
    57 
    58         @Override
    59         public <T> T deserialize(String text, T currentValue, Class<T> type) {
    60                 return ParamsUtil.deserialize(text, type);
    61         }
     52        // @Override
     53        // public <T> String serialize(T value) {
     54        //      return ParamsUtil.serialize(value);
     55        // }
    6256
    6357}
  • java/main/src/main/java/com/framsticks/params/types/StringParam.java

    r105 r107  
    4949        @Override
    5050        public String serialize(Object value) {
     51                if (value == null) {
     52                        return "";
     53                }
    5154                assert value instanceof String;
    5255                String s = (String) value;
  • java/main/src/main/java/com/framsticks/params/types/UniversalParam.java

    r105 r107  
    3535        @Override
    3636        public ReassignResult<Object> reassign(Object newValue, Object oldValue) throws CastFailure {
     37                if (newValue instanceof String) {
     38                        return ReassignResult.create(ParamsUtil.deserialize((String) newValue, Object.class));
     39                }
    3740                return ReassignResult.create(newValue);
    3841        }
     
    4346        }
    4447
    45         @Override
    46         public <T> T deserialize(String text, T currentValue, Class<T> type) {
    47                 return ParamsUtil.deserialize(text, type);
    48         }
    4948
    5049}
Note: See TracChangeset for help on using the changeset viewer.